# HG changeset patch
# User Jacob Carlborg
# Date 1228147620 -3600
# Node ID d8635bb48c7ce0b83ec084338951fc9a5cd6e7ae
# Parent ca5e494f2bbf69967f296bc443df54c9b276a2be
Merge with SWT 3.5
diff -r ca5e494f2bbf -r d8635bb48c7c dwt-cocoa-bindings/bindings.h
--- a/dwt-cocoa-bindings/bindings.h Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-//
-// bindings.h
-// dwt-cocoa-bindings
-//
-// Created by doob on 8/24/08.
-// Copyright 2008 Jacob Carlborg. All rights reserved.
-//
-
-#import
-
-id DCB_NSDefaultRunLoopMode (void);
-
-id DCB_NSDeviceRGBColorSpace(void);
-id DCB_NSAccessibilityPositionAttribute (void);
-id DCB_NSAccessibilitySizeAttribute (void);
-id DCB_NSBackgroundColorAttributeName (void);
-id DCB_NSBaselineOffsetAttributeName (void);
-id DCB_NSDeviceResolution (void);
-id DCB_NSFontAttributeName (void);
-id DCB_NSForegroundColorAttributeName (void);
-id DCB_NSLinkAttributeName (void);
-id DCB_NSParagraphStyleAttributeName (void);
-id DCB_NSStrikethroughColorAttributeName (void);
-id DCB_NSStrikethroughStyleAttributeName (void);
-id DCB_NSUnderlineColorAttributeName (void);
-id DCB_NSUnderlineStyleAttributeName (void);
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt-cocoa-bindings/bindings.m
--- a/dwt-cocoa-bindings/bindings.m Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-//
-// bindings.m
-// dwt-cocoa-bindings
-//
-// Created by doob on 8/24/08.
-// Copyright 2008 Jacob Carlborg. All rights reserved.
-//
-
-#import "bindings.h"
-
-id DCB_NSDefaultRunLoopMode (void)
-{
- return (id)NSDefaultRunLoopMode;
-}
-
-id DCB_NSDeviceRGBColorSpace(void)
-{
- return (id)NSDeviceRGBColorSpace;
-}
-
-id DCB_NSAccessibilityPositionAttribute (void)
-{
- return (id)NSAccessibilityPositionAttribute;
-}
-
-id DCB_NSAccessibilitySizeAttribute (void)
-{
- return (id)NSAccessibilitySizeAttribute;
-}
-
-id DCB_NSBackgroundColorAttributeName (void)
-{
- return (id)NSBackgroundColorAttributeName;
-}
-
-id DCB_NSBaselineOffsetAttributeName (void)
-{
- return (id)NSBaselineOffsetAttributeName;
-}
-
-id DCB_NSDeviceResolution (void)
-{
- return (id)NSDeviceResolution;
-}
-
-id DCB_NSFontAttributeName (void)
-{
- return (id)NSFontAttributeName;
-}
-
-id DCB_NSForegroundColorAttributeName (void)
-{
- return (id)NSForegroundColorAttributeName;
-}
-
-id DCB_NSLinkAttributeName (void)
-{
- return (id)NSLinkAttributeName;
-}
-
-id DCB_NSParagraphStyleAttributeName (void)
-{
- return (id)NSParagraphStyleAttributeName;
-}
-
-id DCB_NSStrikethroughColorAttributeName (void)
-{
- return (id)NSStrikethroughColorAttributeName;
-}
-
-id DCB_NSStrikethroughStyleAttributeName (void)
-{
- return (id)NSStrikethroughStyleAttributeName;
-}
-
-id DCB_NSUnderlineColorAttributeName (void)
-{
- return (id)NSUnderlineColorAttributeName;
-}
-
-id DCB_NSUnderlineStyleAttributeName (void)
-{
- return (id)NSUnderlineStyleAttributeName;
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/DWT.d
--- a/dwt/DWT.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/DWT.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.DWT;
@@ -40,6 +40,8 @@
* HINT may change from release to release, although we typically
* will not withdraw support for a HINT once it is made available.
*
+ *
+ * @see Sample code and further information
*/
/* NOTE:
@@ -414,7 +416,9 @@
* @see dwt.widgets.Display#addFilter
* @see dwt.widgets.Event
*
+ * @see dwt.custom.CCombo#addVerifyListener
* @see dwt.widgets.Combo#addVerifyListener
+ * @see dwt.custom.StyledText#addVerifyListener
* @see dwt.widgets.Text#addVerifyListener
* @see dwt.events.VerifyListener#verifyText
* @see dwt.events.VerifyEvent
@@ -3692,7 +3696,7 @@
/**
* Returns the DWT version number as an integer.
- * Example: "DWT051" is 51
+ * Example: "SWT051" is 51
*
* @return the DWT version number
*/
@@ -3877,7 +3881,7 @@
* to stop the compiler from inlining.
*/
String platform = getPlatform();
- if ("carbon".equals(platform)) { //$NON-NLS-1$
+ if ("carbon".equals (platform) || "cocoa".equals (platform)) { //$NON-NLS-1$ //$NON-NLS-2$
MOD1 = COMMAND;
MOD2 = SHIFT;
MOD3 = ALT;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/DWTError.d
--- a/dwt/DWTError.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/DWTError.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -29,11 +29,11 @@
* throwable that caused the problem (if this information is
* available (i.e. it may be null)).
*
- * SWTErrors are thrown when something fails internally which
+ * DWTErrors are thrown when something fails internally which
* either leaves DWT in an unknown state (eg. the o/s call to
* remove an item from a list returns an error code) or when DWT
* is left in a known-to-be-unrecoverable state (eg. it runs out
- * of callback resources). SWTErrors should not occur in typical
+ * of callback resources). DWTErrors should not occur in typical
* programs, although "high reliability" applications should
* still catch them.
*
@@ -45,6 +45,7 @@
*
* @see DWTException
* @see DWT#error(int)
+ * @see Sample code and further information
*/
public class DWTError : Error {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/DWTException.d
--- a/dwt/DWTException.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/DWTException.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -29,13 +29,14 @@
* exception that caused the problem (if this information is
* available (i.e. it may be null)).
*
- * SWTExceptions are thrown when something fails internally,
+ * DWTExceptions are thrown when something fails internally,
* but DWT is left in a known stable state (eg. a widget call
* was made from a non-u/i thread, or there is failure while
* reading an Image because the source file was corrupt).
*
*
* @see DWTError
+ * @see Sample code and further information
*/
public class DWTException : RuntimeException {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/accessibility/ACC.d
--- a/dwt/accessibility/ACC.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/accessibility/ACC.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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
@@ -9,13 +9,15 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.accessibility.ACC;
/**
* Class ACC contains all the constants used in defining an
* Accessible object.
+ *
+ * @see Sample code and further information
*
* @since 2.0
*/
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/accessibility/Accessible.d
--- a/dwt/accessibility/Accessible.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/accessibility/Accessible.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -9,13 +9,37 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.accessibility.Accessible;
import dwt.dwthelper.utils;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Vector;
+
+import dwt.DWT;
import dwt.DWTException;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSMutableArray;
+import dwt.internal.cocoa.NSNumber;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSValue;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.id;
+import dwt.widgets.Composite;
import dwt.widgets.Control;
+import dwt.widgets.Display;
+import dwt.widgets.Monitor;
+import dwt.widgets.Shell;
import dwt.accessibility.AccessibleListener;
import dwt.accessibility.AccessibleControlListener;
@@ -39,13 +63,55 @@
* @see AccessibleEvent
* @see AccessibleControlListener
* @see AccessibleControlEvent
+ * @see Accessibility snippets
+ * @see Sample code and further information
*
* @since 2.0
*/
public class Accessible {
+
+ static NSString[] baseAttributes = {
+ OS.NSAccessibilityRoleAttribute,
+ OS.NSAccessibilityRoleDescriptionAttribute,
+ OS.NSAccessibilityHelpAttribute,
+ OS.NSAccessibilityFocusedAttribute,
+ OS.NSAccessibilityParentAttribute,
+ OS.NSAccessibilityChildrenAttribute,
+ OS.NSAccessibilityPositionAttribute,
+ OS.NSAccessibilitySizeAttribute,
+ OS.NSAccessibilityWindowAttribute,
+ OS.NSAccessibilityTopLevelUIElementAttribute
+ };
+
+ static NSString[] baseTextAttributes = {
+ OS.NSAccessibilityNumberOfCharactersAttribute,
+ OS.NSAccessibilitySelectedTextAttribute,
+ OS.NSAccessibilitySelectedTextRangeAttribute,
+ OS.NSAccessibilityInsertionPointLineNumberAttribute,
+ OS.NSAccessibilitySelectedTextRangesAttribute,
+ OS.NSAccessibilityVisibleCharacterRangeAttribute,
+ OS.NSAccessibilityValueAttribute,
+ };
+
+ static NSString[] baseParameterizedAttributes = {
+ OS.NSAccessibilityStringForRangeParameterizedAttribute,
+ OS.NSAccessibilityRangeForLineParameterizedAttribute,
+ };
+
+
+ NSMutableArray attributeNames = null;
+ NSMutableArray parameterizedAttributeNames = null;
+ NSMutableArray actionNames = null;
+
+ Vector accessibleListeners = new Vector();
+ Vector accessibleControlListeners = new Vector();
+ Vector accessibleTextListeners = new Vector ();
Control control;
+ Map /**/ children = new HashMap();
+
this (Control control) {
+
this.control = control;
}
@@ -88,28 +154,9 @@
* @see #removeAccessibleListener
*/
public void addAccessibleListener (AccessibleListener listener) {
- }
-
- /**
- * Removes the listener from the collection of listeners who will
- * be notified when an accessible client asks for certain strings,
- * such as name, description, help, or keyboard shortcut.
- *
- * @param listener the listener that should no longer be notified when the receiver
- * is asked for a name, description, help, or keyboard shortcut string
- *
- * @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the listener is null
- *
- * @exception DWTException
- * - ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
- *
- *
- * @see AccessibleListener
- * @see #addAccessibleListener
- */
- public void removeAccessibleListener (AccessibleListener listener) {
+ checkWidget();
+ if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ accessibleListeners.addElement(listener);
}
/**
@@ -133,29 +180,10 @@
* @see AccessibleControlListener
* @see #removeAccessibleControlListener
*/
- public void addAccessibleControlListener (AccessibleControlListener listener) {
- }
-
- /**
- * Removes the listener from the collection of listeners who will
- * be notified when an accessible client asks for custom control
- * specific information.
- *
- * @param listener the listener that should no longer be notified when the receiver
- * is asked for custom control specific information
- *
- * @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the listener is null
- *
- * @exception DWTException
- * - ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
- *
- *
- * @see AccessibleControlListener
- * @see #addAccessibleControlListener
- */
- public void removeAccessibleControlListener (AccessibleControlListener listener) {
+ public void addAccessibleControlListener(AccessibleControlListener listener) {
+ checkWidget();
+ if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ accessibleControlListeners.addElement(listener);
}
/**
@@ -182,6 +210,1053 @@
* @since 3.0
*/
public void addAccessibleTextListener (AccessibleTextListener listener) {
+ checkWidget ();
+ if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+ accessibleTextListeners.addElement (listener);
+ }
+
+ public id internal_accessibilityActionDescription(NSString action, int childID) {
+ // TODO No action support for now.
+ return NSString.stringWith("");
+ }
+
+ public NSArray internal_accessibilityActionNames(int childID) {
+ // The supported action list depends on the role played by the control.
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.detail = -1;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getRole(event);
+ }
+
+ // No accessible listener is overriding the role of the control, so let Cocoa return the default set for the control.
+ if (event.detail is -1) {
+ return null;
+ }
+
+ if ((childID is ACC.CHILDID_SELF) && (actionNames !is null)) {
+ return retainedAutoreleased(actionNames);
+ }
+
+ NSMutableArray returnValue = NSMutableArray.arrayWithCapacity(5);
+
+ switch (event.detail) {
+ case ACC.ROLE_PUSHBUTTON:
+ case ACC.ROLE_RADIOBUTTON:
+ case ACC.ROLE_CHECKBUTTON:
+ case ACC.ROLE_TABITEM:
+ returnValue.addObject(OS.NSAccessibilityPressAction);
+ break;
+ }
+
+ switch (event.detail) {
+ case ACC.ROLE_COMBOBOX:
+ returnValue.addObject(OS.NSAccessibilityConfirmAction);
+ break;
+ }
+
+
+ if (childID is ACC.CHILDID_SELF) {
+ actionNames = returnValue;
+ actionNames.retain();
+ return retainedAutoreleased(actionNames);
+ } else {
+ // Caller must retain if they want to hold on to it.
+ return returnValue;
+ }
+ }
+
+ public NSArray internal_accessibilityAttributeNames(int childID) {
+ // The supported attribute set depends on the role played by the control.
+ // We may need to add or remove from the base set as needed.
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.detail = -1;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getRole(event);
+ }
+
+ // No accessible listener is overriding the role of the control, so let Cocoa
+ // return the default set for the control.
+ if (event.detail is -1)
+ return null;
+
+ if ((childID is ACC.CHILDID_SELF) && (attributeNames !is null)) {
+ return retainedAutoreleased(attributeNames);
+ }
+
+ NSMutableArray returnValue = NSMutableArray.arrayWithCapacity(baseAttributes.length);
+
+ /* Add our list of supported attributes to the array.
+ * Make sure each attribute name is not already in the array before appending.
+ */
+ for (int i = 0; i < baseAttributes.length; i++) {
+ if (!returnValue.containsObject(baseAttributes[i])) {
+ returnValue.addObject(baseAttributes[i]);
+ }
+ }
+
+ if (accessibleTextListeners.size() > 0) {
+ for (int i = 0; i < baseTextAttributes.length; i++) {
+ if (!returnValue.containsObject(baseTextAttributes[i])) {
+ returnValue.addObject(baseTextAttributes[i]);
+ }
+ }
+ }
+
+ // The following are expected to have a value (AXValue)
+ switch (event.detail) {
+ case ACC.ROLE_CHECKBUTTON:
+ case ACC.ROLE_RADIOBUTTON:
+ case ACC.ROLE_LABEL:
+ case ACC.ROLE_TABITEM:
+ case ACC.ROLE_TABFOLDER:
+ returnValue.addObject(OS.NSAccessibilityValueAttribute);
+ break;
+ }
+
+ // The following are expected to report their enabled status (AXEnabled)
+ switch (event.detail) {
+ case ACC.ROLE_CHECKBUTTON:
+ case ACC.ROLE_RADIOBUTTON:
+ case ACC.ROLE_LABEL:
+ case ACC.ROLE_TABITEM:
+ case ACC.ROLE_PUSHBUTTON:
+ case ACC.ROLE_COMBOBOX:
+ returnValue.addObject(OS.NSAccessibilityEnabledAttribute);
+ break;
+ }
+
+ // The following are expected to report a title (AXTitle)
+ switch (event.detail) {
+ case ACC.ROLE_CHECKBUTTON:
+ case ACC.ROLE_RADIOBUTTON:
+ case ACC.ROLE_PUSHBUTTON:
+ case ACC.ROLE_TABITEM:
+ returnValue.addObject(OS.NSAccessibilityTitleAttribute);
+ break;
+ }
+
+ // Accessibility verifier says these attributes must be reported for combo boxes.
+ if (event.detail is ACC.ROLE_COMBOBOX) {
+ returnValue.addObject(OS.NSAccessibilityExpandedAttribute);
+ }
+
+ // Accessibility verifier says these attributes must be reported for tab folders.
+ if (event.detail is ACC.ROLE_TABFOLDER) {
+ returnValue.addObject(OS.NSAccessibilityContentsAttribute);
+ returnValue.addObject(OS.NSAccessibilityTabsAttribute);
+ }
+
+ /*
+ * Only report back sub-roles when the DWT role maps to a sub-role.
+ */
+ if (event.detail !is -1) {
+ String osRole = roleToOs(event.detail);
+
+ if (osRole.indexOf(':') is -1)
+ returnValue.removeObject(OS.NSAccessibilitySubroleAttribute);
+ }
+
+ /*
+ * Children never return their own children, so remove that attribute.
+ */
+ if (childID !is ACC.CHILDID_SELF) {
+ returnValue.removeObject(OS.NSAccessibilityChildrenAttribute);
+ }
+
+ if (childID is ACC.CHILDID_SELF) {
+ attributeNames = returnValue;
+ attributeNames.retain();
+ return retainedAutoreleased(attributeNames);
+ } else {
+ // Caller must retain if necessary.
+ return returnValue;
+ }
+ }
+
+ public id internal_accessibilityAttributeValue(NSString attribute, int childID) {
+ if (attribute.isEqualToString(OS.NSAccessibilityRoleAttribute)) return getRoleAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilitySubroleAttribute)) return getSubroleAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityRoleDescriptionAttribute)) return getRoleDescriptionAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityExpandedAttribute)) return getExpandedAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityHelpAttribute)) return getHelpAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityTitleAttribute)) return getTitleAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityValueAttribute)) return getValueAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityEnabledAttribute)) return getEnabledAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityFocusedAttribute)) return getFocusedAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityParentAttribute)) return getParentAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityChildrenAttribute)) return getChildrenAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityContentsAttribute)) return getChildrenAttribute(childID);
+ // FIXME: There's no specific API just for tabs, which won't include the buttons (if any.)
+ if (attribute.isEqualToString(OS.NSAccessibilityTabsAttribute)) return getTabsAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityWindowAttribute)) return getWindowAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityTopLevelUIElementAttribute)) return getTopLevelUIElementAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityPositionAttribute)) return getPositionAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilitySizeAttribute)) return getSizeAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityDescriptionAttribute)) return getDescriptionAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityNumberOfCharactersAttribute)) return getNumberOfCharactersAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilitySelectedTextAttribute)) return getSelectedTextAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilitySelectedTextRangeAttribute)) return getSelectedTextRangeAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityInsertionPointLineNumberAttribute)) return getInsertionPointLineNumberAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilitySelectedTextRangesAttribute)) return getSelectedTextRangesAttribute(childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityVisibleCharacterRangeAttribute)) return getVisibleCharacterRangeAttribute(childID);
+
+ // If this object don't know how to get the value it's up to the control itself to return an attribute value.
+ return null;
+ }
+
+ public id internal_accessibilityAttributeValue_forParameter(NSString attribute, id parameter, int childID) {
+ if (attribute.isEqualToString(OS.NSAccessibilityStringForRangeParameterizedAttribute)) return getStringForRangeAttribute(parameter, childID);
+ if (attribute.isEqualToString(OS.NSAccessibilityRangeForLineParameterizedAttribute)) return getRangeForLineParameterizedAttribute(parameter, childID);
+ return null;
+ }
+
+ // Returns the UI Element that has the focus. You can assume that the search for the focus has already been narrowed down to the receiver.
+ // Override this method to do a deeper search with a UIElement - e.g. a NSMatrix would determine if one of its cells has the focus.
+ public id internal_accessibilityFocusedUIElement(int childID) {
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = ACC.CHILDID_MULTIPLE; // set to invalid value, to test if the application sets it in getFocus()
+ event.accessible = null;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getFocus(event);
+ }
+
+ // The listener did not respond, so let Cocoa figure it out.
+ if (event.childID is ACC.CHILDID_MULTIPLE)
+ return null;
+
+ /* The application can optionally answer an accessible. */
+ if (event.accessible !is null) {
+ return new id(OS.NSAccessibilityUnignoredAncestor(event.accessible.control.view.id));
+ }
+
+ /* Or the application can answer a valid child ID, including CHILDID_SELF and CHILDID_NONE. */
+ if (event.childID is ACC.CHILDID_SELF || event.childID is ACC.CHILDID_NONE) {
+ return new id(OS.NSAccessibilityUnignoredAncestor(control.view.id));
+ }
+
+ return new id(OS.NSAccessibilityUnignoredAncestor(childIDToOs(event.childID).id));
+ }
+
+ // Returns the deepest descendant of the UIElement hierarchy that contains the point.
+ // You can assume the point has already been determined to lie within the receiver.
+ // Override this method to do deeper hit testing within a UIElement - e.g. a NSMatrix would test its cells. The point is bottom-left relative screen coordinates.
+ public id internal_accessibilityHitTest(NSPoint point, int childID) {
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.x = (int) point.x;
+ Monitor primaryMonitor = Display.getCurrent().getPrimaryMonitor();
+ event.y = (int) (primaryMonitor.getBounds().height - point.y);
+
+ // Set an impossible value to determine if anything responded to the event.
+ event.childID = ACC.CHILDID_MULTIPLE;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getChildAtPoint(event);
+ }
+
+ // The listener did not respond, so let Cocoa figure it out.
+ if (event.childID is ACC.CHILDID_MULTIPLE)
+ return null;
+
+ if (event.accessible !is null) {
+ return new id(OS.NSAccessibilityUnignoredAncestor(event.accessible.control.view.id));
+ }
+
+ if (event.childID is ACC.CHILDID_SELF || event.childID is ACC.CHILDID_NONE) {
+ return new id(OS.NSAccessibilityUnignoredAncestor(control.view.id));
+ }
+
+ return new id(OS.NSAccessibilityUnignoredAncestor(childIDToOs(event.childID).id));
+ }
+
+ public bool internal_accessibilityIsAttributeSettable(NSString attribute, int childID) {
+ return false;
+ }
+
+ // Return YES if the UIElement doesn't show up to the outside world - i.e. its parent should return the UIElement's children as its own - cutting the UIElement out. E.g. NSControls are ignored when they are single-celled.
+ public bool internal_accessibilityIsIgnored(int childID) {
+ return false;
+ }
+
+ // parameterized attribute methods
+ public NSArray internal_accessibilityParameterizedAttributeNames(int childID) {
+
+ if ((childID is ACC.CHILDID_SELF) && (parameterizedAttributeNames !is null)) {
+ return retainedAutoreleased(parameterizedAttributeNames);
+ }
+
+ NSMutableArray returnValue = NSMutableArray.arrayWithCapacity(4);
+
+ if (accessibleTextListeners.size() > 0) {
+ for (int i = 0; i < baseParameterizedAttributes.length; i++) {
+ if (!returnValue.containsObject(baseParameterizedAttributes[i])) {
+ returnValue.addObject(baseParameterizedAttributes[i]);
+ }
+ }
+
+ }
+
+ if (childID is ACC.CHILDID_SELF) {
+ parameterizedAttributeNames = returnValue;
+ parameterizedAttributeNames.retain();
+ return retainedAutoreleased(parameterizedAttributeNames);
+ } else {
+ // Caller must retain if they want to keep it.
+ return returnValue;
+ }
+ }
+
+ public void internal_accessibilityPerformAction(NSString action, int childID) {
+ // TODO Auto-generated method stub
+ // No action support for now.
+ }
+
+ /**
+ * Returns the control for this Accessible object.
+ *
+ * @return the receiver's control
+ * @since 3.0
+ */
+ public Control getControl() {
+ return control;
+ }
+
+ /**
+ * Invokes platform specific functionality to dispose an accessible object.
+ *
+ * IMPORTANT: This method is not part of the public
+ * API for Accessible
. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ *
+ */
+ public void internal_dispose_Accessible() {
+ if (actionNames !is null) actionNames.release();
+ actionNames = null;
+ if (attributeNames !is null) attributeNames.release();
+ attributeNames = null;
+ if (parameterizedAttributeNames !is null) parameterizedAttributeNames.release();
+ parameterizedAttributeNames = null;
+
+ Collection delegates = children.values();
+ Iterator iter = delegates.iterator();
+ while (iter.hasNext()) {
+ SWTAccessibleDelegate childDelegate = (SWTAccessibleDelegate)iter.next();
+ childDelegate.internal_dispose_SWTAccessibleDelegate();
+ }
+
+ children.clear();
+ }
+
+ id getExpandedAttribute(int childID) {
+ // TODO: May need to expand the API so the combo box state can be reported.
+ return NSNumber.numberWithBool(false);
+ }
+
+ id getHelpAttribute (int childID) {
+ id returnValue = null;
+ AccessibleEvent event = new AccessibleEvent(this);
+ event.childID = childID;
+ for (int i = 0; i < accessibleListeners.size(); i++) {
+ AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);
+ listener.getHelp(event);
+ }
+
+ if (event.result !is null) {
+ returnValue = NSString.stringWith(event.result);
+ }
+
+ return returnValue;
+ }
+
+ NSString getRoleAttribute(int childID) {
+ NSString returnValue = null;
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.detail = -1;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getRole(event);
+ }
+ if (event.detail !is -1) {
+ String appRole = roleToOs (event.detail);
+ int index = appRole.indexOf(':');
+ if (index !is -1) appRole = appRole.substring(0, index);
+ returnValue = NSString.stringWith(appRole);
+ }
+
+ return returnValue;
+ }
+
+ id getSubroleAttribute (int childID) {
+ id returnValue = null;
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.detail = -1;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getRole(event);
+ }
+ if (event.detail !is -1) {
+ String appRole = roleToOs (event.detail);
+ int index = appRole.indexOf(':');
+ if (index !is -1) {
+ appRole = appRole.substring(index + 1);
+ returnValue = NSString.stringWith(appRole);
+ }
+ }
+ return returnValue;
+ }
+
+ id getRoleDescriptionAttribute (int childID) {
+ id returnValue = null;
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.detail = -1;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getRole(event);
+ }
+ if (event.detail !is -1) {
+ String appRole = roleToOs (event.detail);
+ String appSubrole = null;
+ int index = appRole.indexOf(':');
+ if (index !is -1) {
+ appSubrole = appRole.substring(index + 1);
+ appRole = appRole.substring(0, index);
+ }
+ NSString nsAppRole = NSString.stringWith(appRole);
+ NSString nsAppSubrole = null;
+
+ if (appSubrole !is null) nsAppSubrole = NSString.stringWith(appSubrole);
+ returnValue = new NSString(OS.NSAccessibilityRoleDescription (((nsAppRole !is null) ? nsAppRole.id : 0), (nsAppSubrole !is null) ? nsAppSubrole.id : 0));
+ }
+ return returnValue;
+ }
+
+ id getTitleAttribute (int childID) {
+
+ id returnValue = null;//NSString.stringWith("");
+
+ /*
+ * Feature of the Macintosh. The text of a Label is returned in its value,
+ * not its title, so ensure that the role is not Label before asking for the title.
+ */
+ AccessibleControlEvent roleEvent = new AccessibleControlEvent(this);
+ roleEvent.childID = childID;
+ roleEvent.detail = -1;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getRole(roleEvent);
+ }
+ if (roleEvent.detail !is ACC.ROLE_LABEL) {
+ AccessibleEvent event = new AccessibleEvent(this);
+ event.childID = childID;
+ event.result = null;
+ for (int i = 0; i < accessibleListeners.size(); i++) {
+ AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);
+ listener.getName(event);
+ }
+
+ if (event.result !is null)
+ returnValue = NSString.stringWith(event.result);
+ }
+ return returnValue;
+ }
+
+ id getValueAttribute (int childID) {
+ id returnValue = null;
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.detail = -1;
+ event.result = null; //TODO: could pass the OS value to the app
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getRole(event);
+ listener.getValue(event);
+ }
+ int role = event.detail;
+ String value = event.result;
+
+ switch (role) {
+ case ACC.ROLE_RADIOBUTTON: // 1 = on, 0 = off
+ case ACC.ROLE_CHECKBUTTON: // 1 = checked, 0 = unchecked, 2 = mixed
+ case ACC.ROLE_SCROLLBAR: // numeric value representing the position of the scroller
+ case ACC.ROLE_SLIDER: // the value associated with the position of the slider thumb
+ case ACC.ROLE_PROGRESSBAR: // the value associated with the fill level of the progress bar
+ if (value !is null) {
+ try {
+ int number = Integer.parseInt(value);
+ returnValue = NSNumber.numberWithInt(number);
+ } catch (NumberFormatException ex) {
+ if (value.equalsIgnoreCase("true")) {
+ returnValue = NSNumber.numberWithBool(true);
+ } else if (value.equalsIgnoreCase("false")) {
+ returnValue = NSNumber.numberWithBool(false);
+ }
+ }
+ } else {
+ returnValue = NSNumber.numberWithBool(false);
+ }
+ break;
+ case ACC.ROLE_TABFOLDER: // the accessibility object representing the currently selected tab item
+ case ACC.ROLE_TABITEM: // 1 = selected, 0 = not selected
+ AccessibleControlEvent ace = new AccessibleControlEvent(this);
+ ace.childID = -4;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getSelection(ace);
+ }
+ if (ace.childID >= ACC.CHILDID_SELF) {
+ if (role is ACC.ROLE_TABITEM) {
+ returnValue = NSNumber.numberWithBool(ace.childID is childID);
+ } else {
+ returnValue = new id(OS.NSAccessibilityUnignoredAncestor(childIDToOs(ace.childID).id));
+ }
+ } else {
+ returnValue = NSNumber.numberWithBool(false);
+ }
+ break;
+ case ACC.ROLE_COMBOBOX: // text of the currently selected item
+ case ACC.ROLE_TEXT: // text in the text field
+ if (value !is null) returnValue = NSString.stringWith(value);
+ break;
+ case ACC.ROLE_LABEL: // text in the label
+ /* On a Mac, the 'value' of a label is the same as the 'name' of the label. */
+ AccessibleEvent e = new AccessibleEvent(this);
+ e.childID = childID;
+ e.result = null;
+ for (int i = 0; i < accessibleListeners.size(); i++) {
+ AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);
+ listener.getName(e);
+ }
+ if (e.result !is null) {
+ returnValue = NSString.stringWith(e.result);
+ } else {
+ if (value !is null) returnValue = NSString.stringWith(value);
+ }
+ break;
+ }
+
+ return returnValue;
+ }
+
+ id getEnabledAttribute (int childID) {
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.detail = -1;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getState(event);
+ }
+
+ return NSNumber.numberWithBool(control.isEnabled());
+ }
+
+ id getFocusedAttribute (int childID) {
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = ACC.CHILDID_MULTIPLE; // set to invalid value, to test if the application sets it in getFocus()
+ event.accessible = null;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getFocus(event);
+ }
+
+ /* The application can optionally answer an accessible. */
+ // FIXME:
+// if (event.accessible !is null) {
+// bool hasFocus = (event.accessible.childID is childID) && (event.accessible.control is this.control);
+// return NSNumber.numberWithBool(hasFocus);
+// }
+
+ /* Or the application can answer a valid child ID, including CHILDID_SELF and CHILDID_NONE. */
+ if (event.childID is ACC.CHILDID_SELF) {
+ bool hasFocus = (event.childID is childID);
+ return NSNumber.numberWithBool(hasFocus);
+ }
+ if (event.childID is ACC.CHILDID_NONE) {
+ return NSNumber.numberWithBool(false);
+ }
+ if (event.childID !is ACC.CHILDID_MULTIPLE) {
+ /* Other valid childID. */
+ return NSNumber.numberWithBool(event.childID is childID);
+ }
+
+ // Invalid childID at this point means the application did not implement getFocus, so
+ // let the default handler return the native focus.
+ bool hasFocus = (this.control.view.window().firstResponder() is control.view);
+ return NSNumber.numberWithBool(hasFocus);
+ }
+
+ id getParentAttribute (int childID) {
+ // Returning null here means 'let Cocoa figure it out.'
+ if (childID is ACC.CHILDID_SELF)
+ return null;
+ else
+ return new id(OS.NSAccessibilityUnignoredAncestor(control.view.id));
+ }
+
+ id getChildrenAttribute (int childID) {
+ id returnValue = null;
+ if (childID is ACC.CHILDID_SELF) {
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.detail = -1; // set to impossible value to test if app resets
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getChildCount(event);
+ }
+ if (event.detail > 0) {
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getChildren(event);
+ }
+ Object [] appChildren = event.children;
+ if (appChildren !is null && appChildren.length > 0) {
+ /* return an NSArray of NSAccessible objects. */
+ NSMutableArray childArray = NSMutableArray.arrayWithCapacity(appChildren.length);
+
+ for (int i = 0; i < appChildren.length; i++) {
+ Object child = appChildren[i];
+ if (child instanceof Integer) {
+ id accChild = childIDToOs(((Integer)child).intValue());
+ childArray.addObject(accChild);
+ } else {
+ childArray.addObject(((Accessible)child).control.view);
+ }
+ }
+
+ returnValue = new id(OS.NSAccessibilityUnignoredChildren(childArray.id));
+ }
+ }
+ } else {
+ // Lightweight children have no children of their own.
+ // Don't return null if there are no children -- always return an empty array.
+ returnValue = NSArray.array();
+ }
+
+ // Returning null here means we want the control itself to determine its children. If the accessible listener
+ // implemented getChildCount/getChildren, references to those objects would have been returned above.
+ return returnValue;
+ }
+
+ id getTabsAttribute (int childID) {
+ id returnValue = null;
+ if (childID is ACC.CHILDID_SELF) {
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.detail = -1; // set to impossible value to test if app resets
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getChildCount(event);
+ }
+ if (event.detail > 0) {
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getChildren(event);
+ }
+ Object [] appChildren = event.children;
+ if (appChildren !is null && appChildren.length > 0) {
+ /* return an NSArray of NSAccessible objects. */
+ NSMutableArray childArray = NSMutableArray.arrayWithCapacity(appChildren.length);
+
+ for (int i = 0; i < appChildren.length; i++) {
+ Object child = appChildren[i];
+ if (child instanceof Integer) {
+ int subChildID = ((Integer)child).intValue();
+ event.childID = subChildID;
+ event.detail = -1;
+ for (int j = 0; j < accessibleControlListeners.size(); j++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(j);
+ listener.getRole(event);
+ }
+
+ if (event.detail is ACC.ROLE_TABITEM) {
+ id accChild = childIDToOs(((Integer)child).intValue());
+ childArray.addObject(accChild);
+ }
+ } else {
+ childArray.addObject(((Accessible)child).control.view);
+ }
+ }
+
+ returnValue = new id(OS.NSAccessibilityUnignoredChildren(childArray.id));
+ }
+ }
+ } else {
+ // Lightweight children have no children of their own.
+ // Don't return null if there are no children -- always return an empty array.
+ returnValue = NSArray.array();
+ }
+
+ // Returning null here means we want the control itself to determine its children. If the accessible listener
+ // implemented getChildCount/getChildren, references to those objects would have been returned above.
+ return returnValue;
+ }
+
+ id getWindowAttribute (int childID) {
+ return control.view.window();
+ }
+
+ id getTopLevelUIElementAttribute (int childID) {
+ return control.view.window();
+ }
+
+ id getPositionAttribute (int childID) {
+ id returnValue = null;
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.width = -1;
+
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getLocation(event);
+ }
+
+ Monitor primaryMonitor = Display.getCurrent().getPrimaryMonitor();
+
+ NSPoint osPositionAttribute = new NSPoint ();
+ if (event.width !is -1) {
+ // The point returned is the lower-left coordinate of the widget in lower-left relative screen coordinates.
+ osPositionAttribute.x = event.x;
+ osPositionAttribute.y = primaryMonitor.getBounds().height - event.y - event.height;
+ returnValue = NSValue.valueWithPoint(osPositionAttribute);
+ } else {
+ if (childID !is ACC.CHILDID_SELF) {
+ Point pt = null;
+ Rectangle location = control.getBounds();
+
+ if (control.getParent() !is null)
+ pt = control.getParent().toDisplay(location.x, location.y);
+ else
+ pt = ((Shell)control).toDisplay(location.x, location.y);
+
+ osPositionAttribute.x = pt.x;
+ osPositionAttribute.y = pt.y;
+ returnValue = NSValue.valueWithPoint(osPositionAttribute);
+ }
+ }
+
+ return returnValue;
+ }
+
+ id getSizeAttribute (int childID) {
+ id returnValue = null;
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.width = -1;
+
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getLocation(event);
+ }
+
+ NSSize controlSize = new NSSize ();
+ if (event.width !is -1) {
+ controlSize.width = event.width;
+ controlSize.height = event.height;
+ returnValue = NSValue.valueWithSize(controlSize);
+ } else {
+ if (childID !is ACC.CHILDID_SELF) {
+ controlSize.width = controlSize.height = 0;
+ returnValue = NSValue.valueWithSize(controlSize);
+ }
+ }
+
+ return returnValue;
+ }
+
+ id getDescriptionAttribute (int childID) {
+ AccessibleEvent event = new AccessibleEvent(this);
+ event.childID = childID;
+ event.result = null;
+ id returnValue = null;
+ for (int i = 0; i < accessibleListeners.size(); i++) {
+ AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);
+ listener.getDescription(event);
+ }
+
+ returnValue = (event.result !is null ? NSString.stringWith(event.result) : null);
+
+ // If no description was provided, try the name.
+ if (returnValue is null) {
+ if (control instanceof Composite) returnValue = NSString.stringWith("");
+ }
+
+ return returnValue;
+ }
+
+ id getInsertionPointLineNumberAttribute (int childID) {
+ id returnValue = null;
+ AccessibleControlEvent controlEvent = new AccessibleControlEvent(this);
+ controlEvent.childID = childID;
+ controlEvent.result = null;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getValue(controlEvent);
+ }
+ AccessibleTextEvent textEvent = new AccessibleTextEvent(this);
+ textEvent.childID = childID;
+ textEvent.offset = -1;
+ for (int i = 0; i < accessibleTextListeners.size(); i++) {
+ AccessibleTextListener listener = (AccessibleTextListener) accessibleTextListeners.elementAt(i);
+ listener.getCaretOffset(textEvent);
+ }
+ if (controlEvent.result !is null && textEvent.offset !is -1) {
+ int lineNumber = lineNumberForOffset (controlEvent.result, textEvent.offset);
+ returnValue = NSNumber.numberWithInt(lineNumber);
+ }
+ return returnValue;
+ }
+
+ id getNumberOfCharactersAttribute (int childID) {
+ id returnValue = null;
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.result = null;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getValue(event);
+ }
+ String appValue = event.result;
+ if (appValue !is null) {
+ returnValue = NSNumber.numberWithInt(appValue.length());
+ }
+ return returnValue;
+ }
+
+ id getRangeForLineParameterizedAttribute (id parameter, int childID) {
+ id returnValue = null;
+
+ // The parameter is an NSNumber with the line number.
+ NSNumber lineNumberObj = new NSNumber(parameter.id);
+ int lineNumber = lineNumberObj.intValue();
+ System.out.println("Line number = " + lineNumber);
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.result = null;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getValue(event);
+ }
+ if (event.result !is null) {
+ NSRange range = rangeForLineNumber (lineNumber, event.result);
+ if (range.location !is -1) {
+ returnValue = NSValue.valueWithRange(range);
+ }
+ }
+ return returnValue;
+ }
+
+ id getSelectedTextAttribute (int childID) {
+ id returnValue = NSString.stringWith("");
+ AccessibleTextEvent event = new AccessibleTextEvent(this);
+ event.childID = childID;
+ event.offset = -1;
+ event.length = -1;
+ for (int i = 0; i < accessibleTextListeners.size(); i++) {
+ AccessibleTextListener listener = (AccessibleTextListener) accessibleTextListeners.elementAt(i);
+ listener.getSelectionRange(event);
+ }
+ int offset = event.offset;
+ int length = event.length;
+ if (offset !is -1 && length !is -1 && length !is 0) { // TODO: do we need the && length !is 0 ?
+ AccessibleControlEvent event2 = new AccessibleControlEvent(this);
+ event2.childID = event.childID;
+ event2.result = null;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getValue(event2);
+ }
+ String appValue = event2.result;
+ if (appValue !is null) {
+ returnValue = NSString.stringWith(appValue.substring(offset, offset + length));
+ }
+ }
+ return returnValue;
+ }
+
+ id getSelectedTextRangeAttribute (int childID) {
+ id returnValue = null;
+ AccessibleTextEvent event = new AccessibleTextEvent(this);
+ event.childID = childID;
+ event.offset = -1;
+ event.length = 0;
+ for (int i = 0; i < accessibleTextListeners.size(); i++) {
+ AccessibleTextListener listener = (AccessibleTextListener) accessibleTextListeners.elementAt(i);
+ listener.getSelectionRange(event);
+ }
+ if (event.offset !is -1) {
+ NSRange range = new NSRange();
+ range.location = event.offset;
+ range.length = event.length;
+ returnValue = NSValue.valueWithRange(range);
+ }
+ return returnValue;
+ }
+
+ id getStringForRangeAttribute (id parameter, int childID) {
+ id returnValue = null;
+
+ // Parameter is an NSRange wrapped in an NSValue.
+ NSValue parameterObject = new NSValue(parameter.id);
+ NSRange range = parameterObject.rangeValue();
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.result = null;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getValue(event);
+ }
+ String appValue = event.result;
+
+ if (appValue !is null) {
+ returnValue = NSString.stringWith(appValue.substring(range.location, range.location + range.length));
+ }
+
+ return returnValue;
+ }
+
+ id getSelectedTextRangesAttribute (int childID) {
+ NSMutableArray returnValue = null;
+ AccessibleTextEvent event = new AccessibleTextEvent(this);
+ event.childID = childID;
+ event.offset = -1;
+ event.length = 0;
+
+ for (int i = 0; i < accessibleTextListeners.size(); i++) {
+ AccessibleTextListener listener = (AccessibleTextListener) accessibleTextListeners.elementAt(i);
+ listener.getSelectionRange(event);
+ }
+
+ if (event.offset !is -1) {
+ returnValue = NSMutableArray.arrayWithCapacity(1);
+ NSRange range = new NSRange();
+ range.location = event.offset;
+ range.length = event.length;
+ returnValue.addObject(NSValue.valueWithRange(range));
+ }
+
+ return returnValue;
+ }
+
+ id getVisibleCharacterRangeAttribute (int childID) {
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = childID;
+ event.result = null;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getValue(event);
+ }
+
+ NSRange range = new NSRange();
+
+ if (event.result !is null) {
+ range.location = 0;
+ range.length = event.result.length();
+ } else {
+ return null;
+// range.location = range.length = 0;
+ }
+
+ return NSValue.valueWithRange(range);
+ }
+
+ int lineNumberForOffset (String text, int offset) {
+ int lineNumber = 1;
+ int length = text.length();
+ for (int i = 0; i < offset; i++) {
+ switch (text.charAt (i)) {
+ case '\r':
+ if (i + 1 < length) {
+ if (text.charAt (i + 1) is '\n') ++i;
+ }
+ // FALL THROUGH
+ case '\n':
+ lineNumber++;
+ }
+ }
+ return lineNumber;
+ }
+
+ NSRange rangeForLineNumber (int lineNumber, String text) {
+ NSRange range = new NSRange();
+ range.location = -1;
+ int line = 1;
+ int count = 0;
+ int length = text.length ();
+ for (int i = 0; i < length; i++) {
+ if (line is lineNumber) {
+ if (count is 0) {
+ range.location = i;
+ }
+ count++;
+ }
+ if (line > lineNumber) break;
+ switch (text.charAt (i)) {
+ case '\r':
+ if (i + 1 < length && text.charAt (i + 1) is '\n') i++;
+ // FALL THROUGH
+ case '\n':
+ line++;
+ }
+ }
+ range.length = count;
+ return range;
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will
+ * be notified when an accessible client asks for certain strings,
+ * such as name, description, help, or keyboard shortcut.
+ *
+ * @param listener the listener that should no longer be notified when the receiver
+ * is asked for a name, description, help, or keyboard shortcut string
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception DWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
+ *
+ *
+ * @see AccessibleListener
+ * @see #addAccessibleListener
+ */
+ public void removeAccessibleListener(AccessibleListener listener) {
+ checkWidget();
+ if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ accessibleListeners.removeElement(listener);
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will
+ * be notified when an accessible client asks for custom control
+ * specific information.
+ *
+ * @param listener the listener that should no longer be notified when the receiver
+ * is asked for custom control specific information
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception DWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
+ *
+ *
+ * @see AccessibleControlListener
+ * @see #addAccessibleControlListener
+ */
+ public void removeAccessibleControlListener(AccessibleControlListener listener) {
+ checkWidget();
+ if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ accessibleControlListeners.removeElement(listener);
}
/**
@@ -206,18 +1281,17 @@
* @since 3.0
*/
public void removeAccessibleTextListener (AccessibleTextListener listener) {
+ checkWidget ();
+ if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+ accessibleTextListeners.removeElement (listener);
}
- /**
- * Returns the control for this Accessible object.
- *
- * @return the receiver's control
- * @since 3.0
- */
- public Control getControl () {
- return control;
+ static NSArray retainedAutoreleased(NSArray inObject) {
+ id temp = inObject.retain();
+ id temp2 = new NSObject(temp.id).autorelease();
+ return new NSArray(temp2.id);
}
-
+
/**
* Sends a message to accessible clients that the child selection
* within a custom container control has changed.
@@ -230,6 +1304,24 @@
* @since 3.0
*/
public void selectionChanged () {
+ checkWidget();
+ OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilitySelectedChildrenChangedNotification.id);
+ }
+
+ /**
+ * Sends a message to accessible clients indicating that the focus
+ * has changed within a custom control.
+ *
+ * @param childID an identifier specifying a child of the control
+ *
+ * @exception DWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
+ *
+ */
+ public void setFocus(int childID) {
+ checkWidget();
+ OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilityFocusedUIElementChangedNotification.id);
}
/**
@@ -246,6 +1338,8 @@
* @since 3.0
*/
public void textCaretMoved (int index) {
+ checkWidget();
+ OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilitySelectedTextChangedNotification.id);
}
/**
@@ -268,6 +1362,8 @@
* @since 3.0
*/
public void textChanged (int type, int startIndex, int length) {
+ checkWidget();
+ OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilityValueChangedNotification.id);
}
/**
@@ -282,46 +1378,124 @@
* @since 3.0
*/
public void textSelectionChanged () {
+ checkWidget();
+ OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilitySelectedTextChangedNotification.id);
}
+
+ id childIDToOs(int childID) {
+ if (childID is ACC.CHILDID_SELF) {
+ return control.view;
+ }
- /**
- * Sends a message to accessible clients indicating that the focus
- * has changed within a custom control.
- *
- * @param childID an identifier specifying a child of the control
- *
- * @exception DWTException
- * - ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
- *
- */
- public void setFocus (int childID) {
+ /* Check cache for childID, if found, return corresponding osChildID. */
+ SWTAccessibleDelegate childRef = (SWTAccessibleDelegate) children.get(new Integer(childID));
+
+ if (childRef is null) {
+ childRef = new SWTAccessibleDelegate(this, childID);
+ children.put(new Integer(childID), childRef);
+ }
+
+ return childRef;
}
- /**
- * Invokes platform specific functionality to dispose an accessible object.
- *
- * IMPORTANT: This method is not part of the public
- * API for Accessible
. It is marked public only so that it
- * can be shared within the packages provided by DWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- *
- */
- public void internal_dispose_Accessible () {
+ NSString concatStringsAsRole(NSString str1, NSString str2) {
+ NSString returnValue = str1;
+ returnValue = returnValue.stringByAppendingString(NSString.stringWith(":"));
+ returnValue = returnValue.stringByAppendingString(str2);
+ return returnValue;
+ }
+
+ String roleToOs(int role) {
+ NSString nsReturnValue = null; //OS.NSAccessibilityUnknownRole;
+
+ switch (role) {
+ case ACC.ROLE_CLIENT_AREA: nsReturnValue = OS.NSAccessibilityGroupRole; break;
+ case ACC.ROLE_WINDOW: nsReturnValue = OS.NSAccessibilityWindowRole; break;
+ case ACC.ROLE_MENUBAR: nsReturnValue = OS.NSAccessibilityMenuBarRole; break;
+ case ACC.ROLE_MENU: nsReturnValue = OS.NSAccessibilityMenuRole; break;
+ case ACC.ROLE_MENUITEM: nsReturnValue = OS.NSAccessibilityMenuItemRole; break;
+ case ACC.ROLE_SEPARATOR: nsReturnValue = OS.NSAccessibilitySplitterRole; break;
+ case ACC.ROLE_TOOLTIP: nsReturnValue = OS.NSAccessibilityHelpTagRole; break;
+ case ACC.ROLE_SCROLLBAR: nsReturnValue = OS.NSAccessibilityScrollBarRole; break;
+ case ACC.ROLE_DIALOG: nsReturnValue = concatStringsAsRole(OS.NSAccessibilityWindowRole, OS.NSAccessibilityDialogSubrole); break;
+ case ACC.ROLE_LABEL: nsReturnValue = OS.NSAccessibilityStaticTextRole; break;
+ case ACC.ROLE_PUSHBUTTON: nsReturnValue = OS.NSAccessibilityButtonRole; break;
+ case ACC.ROLE_CHECKBUTTON: nsReturnValue = OS.NSAccessibilityCheckBoxRole; break;
+ case ACC.ROLE_RADIOBUTTON: nsReturnValue = OS.NSAccessibilityRadioButtonRole; break;
+ case ACC.ROLE_COMBOBOX: nsReturnValue = OS.NSAccessibilityComboBoxRole; break;
+ case ACC.ROLE_TEXT: {
+ int style = control.getStyle();
+
+ if ((style & DWT.MULTI) !is 0) {
+ nsReturnValue = OS.NSAccessibilityTextAreaRole;
+ } else {
+ nsReturnValue = OS.NSAccessibilityTextFieldRole;
+ }
+
+ break;
+ }
+ case ACC.ROLE_TOOLBAR: nsReturnValue = OS.NSAccessibilityToolbarRole; break;
+ case ACC.ROLE_LIST: nsReturnValue = OS.NSAccessibilityOutlineRole; break;
+ case ACC.ROLE_LISTITEM: nsReturnValue = OS.NSAccessibilityStaticTextRole; break;
+ case ACC.ROLE_TABLE: nsReturnValue = OS.NSAccessibilityTableRole; break;
+ case ACC.ROLE_TABLECELL: nsReturnValue = concatStringsAsRole(OS.NSAccessibilityRowRole, OS.NSAccessibilityTableRowSubrole); break;
+ case ACC.ROLE_TABLECOLUMNHEADER: nsReturnValue = OS.NSAccessibilitySortButtonRole; break;
+ case ACC.ROLE_TABLEROWHEADER: nsReturnValue = concatStringsAsRole(OS.NSAccessibilityRowRole, OS.NSAccessibilityTableRowSubrole); break;
+ case ACC.ROLE_TREE: nsReturnValue = OS.NSAccessibilityOutlineRole; break;
+ case ACC.ROLE_TREEITEM: nsReturnValue = concatStringsAsRole(OS.NSAccessibilityOutlineRole, OS.NSAccessibilityOutlineRowSubrole); break;
+ case ACC.ROLE_TABFOLDER: nsReturnValue = OS.NSAccessibilityTabGroupRole; break;
+ case ACC.ROLE_TABITEM: nsReturnValue = OS.NSAccessibilityRadioButtonRole; break;
+ case ACC.ROLE_PROGRESSBAR: nsReturnValue = OS.NSAccessibilityProgressIndicatorRole; break;
+ case ACC.ROLE_SLIDER: nsReturnValue = OS.NSAccessibilitySliderRole; break;
+ case ACC.ROLE_LINK: nsReturnValue = OS.NSAccessibilityLinkRole; break;
+ }
+
+ return nsReturnValue.getString();
}
- /**
- * Invokes platform specific functionality to handle a window message.
- *
- * IMPORTANT: This method is not part of the public
- * API for Accessible
. It is marked public only so that it
- * can be shared within the packages provided by DWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- *
- */
- public int internal_WM_GETOBJECT (int wParam, int lParam) {
- return 0;
+ int osToRole(NSString osRole) {
+ if (osRole is null) return 0;
+ if (osRole.isEqualToString(OS.NSAccessibilityWindowRole)) return ACC.ROLE_WINDOW;
+ if (osRole.isEqualToString(OS.NSAccessibilityMenuBarRole)) return ACC.ROLE_MENUBAR;
+ if (osRole.isEqualToString(OS.NSAccessibilityMenuRole)) return ACC.ROLE_MENU;
+ if (osRole.isEqualToString(OS.NSAccessibilityMenuItemRole)) return ACC.ROLE_MENUITEM;
+ if (osRole.isEqualToString(OS.NSAccessibilitySplitterRole)) return ACC.ROLE_SEPARATOR;
+ if (osRole.isEqualToString(OS.NSAccessibilityHelpTagRole)) return ACC.ROLE_TOOLTIP;
+ if (osRole.isEqualToString(OS.NSAccessibilityScrollBarRole)) return ACC.ROLE_SCROLLBAR;
+ if (osRole.isEqualToString(OS.NSAccessibilityScrollAreaRole)) return ACC.ROLE_LIST;
+ if (osRole.isEqualToString(concatStringsAsRole(OS.NSAccessibilityWindowRole, OS.NSAccessibilityDialogSubrole))) return ACC.ROLE_DIALOG;
+ if (osRole.isEqualToString(concatStringsAsRole(OS.NSAccessibilityWindowRole, OS.NSAccessibilitySystemDialogSubrole))) return ACC.ROLE_DIALOG;
+ if (osRole.isEqualToString(OS.NSAccessibilityStaticTextRole)) return ACC.ROLE_LABEL;
+ if (osRole.isEqualToString(OS.NSAccessibilityButtonRole)) return ACC.ROLE_PUSHBUTTON;
+ if (osRole.isEqualToString(OS.NSAccessibilityCheckBoxRole)) return ACC.ROLE_CHECKBUTTON;
+ if (osRole.isEqualToString(OS.NSAccessibilityRadioButtonRole)) return ACC.ROLE_RADIOBUTTON;
+ if (osRole.isEqualToString(OS.NSAccessibilityComboBoxRole)) return ACC.ROLE_COMBOBOX;
+ if (osRole.isEqualToString(OS.NSAccessibilityTextFieldRole)) return ACC.ROLE_TEXT;
+ if (osRole.isEqualToString(OS.NSAccessibilityTextAreaRole)) return ACC.ROLE_TEXT;
+ if (osRole.isEqualToString(OS.NSAccessibilityToolbarRole)) return ACC.ROLE_TOOLBAR;
+ if (osRole.isEqualToString(OS.NSAccessibilityListRole)) return ACC.ROLE_LIST;
+ if (osRole.isEqualToString(OS.NSAccessibilityTableRole)) return ACC.ROLE_TABLE;
+ if (osRole.isEqualToString(OS.NSAccessibilityColumnRole)) return ACC.ROLE_TABLECOLUMNHEADER;
+ if (osRole.isEqualToString(concatStringsAsRole(OS.NSAccessibilityButtonRole, OS.NSAccessibilitySortButtonRole))) return ACC.ROLE_TABLECOLUMNHEADER;
+ if (osRole.isEqualToString(concatStringsAsRole(OS.NSAccessibilityRowRole, OS.NSAccessibilityTableRowSubrole))) return ACC.ROLE_TABLEROWHEADER;
+ if (osRole.isEqualToString(OS.NSAccessibilityOutlineRole)) return ACC.ROLE_TREE;
+ if (osRole.isEqualToString(concatStringsAsRole(OS.NSAccessibilityOutlineRole, OS.NSAccessibilityOutlineRowSubrole))) return ACC.ROLE_TREEITEM;
+ if (osRole.isEqualToString(OS.NSAccessibilityTabGroupRole)) return ACC.ROLE_TABFOLDER;
+ if (osRole.isEqualToString(OS.NSAccessibilityProgressIndicatorRole)) return ACC.ROLE_PROGRESSBAR;
+ if (osRole.isEqualToString(OS.NSAccessibilitySliderRole)) return ACC.ROLE_SLIDER;
+ if (osRole.isEqualToString(OS.NSAccessibilityLinkRole)) return ACC.ROLE_LINK;
+ return ACC.ROLE_CLIENT_AREA;
}
+
+ /* checkWidget was copied from Widget, and rewritten to work in this package */
+ void checkWidget () {
+ if (!isValidThread ()) DWT.error (DWT.ERROR_THREAD_INVALID_ACCESS);
+ if (control.isDisposed ()) DWT.error (DWT.ERROR_WIDGET_DISPOSED);
+ }
+
+ /* isValidThread was copied from Widget, and rewritten to work in this package */
+ bool isValidThread () {
+ return control.getDisplay ().getThread () is Thread.currentThread ();
+ }
+
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/accessibility/AccessibleAdapter.d
--- a/dwt/accessibility/AccessibleAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/accessibility/AccessibleAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.accessibility.AccessibleAdapter;
@@ -33,6 +33,7 @@
*
* @see AccessibleListener
* @see AccessibleEvent
+ * @see Sample code and further information
*
* @since 2.0
*/
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/accessibility/AccessibleControlAdapter.d
--- a/dwt/accessibility/AccessibleControlAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/accessibility/AccessibleControlAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.accessibility.AccessibleControlAdapter;
@@ -39,6 +39,7 @@
*
* @see AccessibleControlListener
* @see AccessibleControlEvent
+ * @see Sample code and further information
*
* @since 2.0
*/
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/accessibility/AccessibleControlEvent.d
--- a/dwt/accessibility/AccessibleControlEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/accessibility/AccessibleControlEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.accessibility.AccessibleControlEvent;
@@ -33,6 +33,7 @@
*
* @see AccessibleControlListener
* @see AccessibleControlAdapter
+ * @see Sample code and further information
*
* @since 2.0
*/
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/accessibility/AccessibleControlListener.d
--- a/dwt/accessibility/AccessibleControlListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/accessibility/AccessibleControlListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.accessibility.AccessibleControlListener;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/accessibility/AccessibleEvent.d
--- a/dwt/accessibility/AccessibleEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/accessibility/AccessibleEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.accessibility.AccessibleEvent;
@@ -30,6 +30,7 @@
*
* @see AccessibleListener
* @see AccessibleAdapter
+ * @see Sample code and further information
*
* @since 2.0
*/
@@ -62,10 +63,10 @@
}
/**
- * Returns a String containing a concise, human-readable
+ * Returns a string containing a concise, human-readable
* description of the receiver.
*
- * @return a String representation of the event
+ * @return a string representation of the event
*/
public String toString () {
return Format("AccessibleEvent {childID={}{}{}{}" , childID , " result=" , result , "}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/accessibility/AccessibleListener.d
--- a/dwt/accessibility/AccessibleListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/accessibility/AccessibleListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.accessibility.AccessibleListener;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/accessibility/AccessibleTextAdapter.d
--- a/dwt/accessibility/AccessibleTextAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/accessibility/AccessibleTextAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.accessibility.AccessibleTextAdapter;
@@ -39,6 +39,7 @@
*
* @see AccessibleTextListener
* @see AccessibleTextEvent
+ * @see Sample code and further information
*
* @since 3.0
*/
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/accessibility/AccessibleTextEvent.d
--- a/dwt/accessibility/AccessibleTextEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/accessibility/AccessibleTextEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.accessibility.AccessibleTextEvent;
@@ -32,6 +32,7 @@
*
* @see AccessibleTextListener
* @see AccessibleTextAdapter
+ * @see Sample code and further information
*
* @since 3.0
*/
@@ -51,10 +52,10 @@
}
/**
- * Returns a String containing a concise, human-readable
+ * Returns a string containing a concise, human-readable
* description of the receiver.
*
- * @return a String representation of the event
+ * @return a string representation of the event
*/
public String toString () {
return Format("AccessibleTextEvent {childID={}{}{}{}{}{}" , childID , //$NON-NLS-1$
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/accessibility/AccessibleTextListener.d
--- a/dwt/accessibility/AccessibleTextListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/accessibility/AccessibleTextListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.accessibility.AccessibleTextListener;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/accessibility/SWTAccessibleDelegate.d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/accessibility/SWTAccessibleDelegate.d Mon Dec 01 17:07:00 2008 +0100
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.accessibility.SWTAccessibleDelegate;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.internal.C;
+import dwt.internal.Callback;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.id;
+
+class SWTAccessibleDelegate extends NSObject {
+
+ /**
+ * Accessible Key: The string constant for looking up the accessible
+ * for a control using getData(String)
. When an accessible
+ * is created for a control, it is stored as a property in the control
+ * using setData(String, Object)
.
+ */
+ static final String ACCESSIBLE_KEY = "Accessible"; //$NON-NLS-1$
+ static final String DWT_OBJECT = "DWT_OBJECT";
+
+ static Callback accessible2Args, accessible3Args, accessible4Args;
+ static int /*long*/ proc2Args, proc3Args, proc4Args;
+
+ Accessible accessibleParent;
+ int /*long*/ delegateJniRef;
+ int childID;
+
+ NSArray attributeNames = null;
+ NSArray parameterizedAttributeNames = null;
+ NSArray actionNames = null;
+
+ static {
+ Class clazz = SWTAccessibleDelegate.class;
+
+ accessible2Args = new Callback(clazz, "accessibleProc", 2);
+ proc2Args = accessible2Args.getAddress();
+ if (proc2Args is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+
+ accessible3Args = new Callback(clazz, "accessibleProc", 3);
+ proc3Args = accessible3Args.getAddress();
+ if (proc3Args is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+
+ accessible4Args = new Callback(clazz, "accessibleProc", 4);
+ proc4Args = accessible3Args.getAddress();
+ if (proc4Args is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+
+ // Accessible custom controls need to implement the NSAccessibility protocol. To do that,
+ // we dynamically add the methods to the control's class that are required
+ // by NSAccessibility. Then, when external assistive technology services are used,
+ // those methods get called to provide the needed information.
+
+ String className = "SWTAccessibleDelegate";
+
+ // TODO: These should either move out of Display or be accessible to this class.
+ String types = "*";
+ int size = C.PTR_SIZEOF, align = C.PTR_SIZEOF is 4 ? 2 : 3;
+
+ int /*long*/ cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+ OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types);
+
+ // Add the NSAccessibility overrides
+ OS.class_addMethod(cls, OS.sel_accessibilityActionNames, proc2Args, "@:");
+ OS.class_addMethod(cls, OS.sel_accessibilityAttributeNames, proc2Args, "@:");
+ OS.class_addMethod(cls, OS.sel_accessibilityParameterizedAttributeNames, proc2Args, "@:");
+ OS.class_addMethod(cls, OS.sel_accessibilityIsIgnored, proc2Args, "@:");
+ OS.class_addMethod(cls, OS.sel_accessibilityFocusedUIElement, proc2Args, "@:");
+
+ OS.class_addMethod(cls, OS.sel_accessibilityAttributeValue_, proc3Args, "@:@");
+ OS.class_addMethod(cls, OS.sel_accessibilityHitTest_, proc3Args, "@:{NSPoint}");
+ OS.class_addMethod(cls, OS.sel_accessibilityIsAttributeSettable_, proc3Args, "@:@");
+ OS.class_addMethod(cls, OS.sel_accessibilityActionDescription_, proc3Args, "@:@");
+ OS.class_addMethod(cls, OS.sel_accessibilityPerformAction_, proc3Args, "@:@");
+
+ OS.class_addMethod(cls, OS.sel_accessibilityAttributeValue_forParameter_, proc4Args, "@:@@");
+ OS.class_addMethod(cls, OS.sel_accessibilitySetValue_forAttribute_, proc4Args, "@:@@");
+
+ OS.objc_registerClassPair(cls);
+ }
+
+
+ public SWTAccessibleDelegate(Accessible accessible, int childID) {
+ super(0);
+ this.accessibleParent = accessible;
+ this.childID = childID;
+ alloc().init();
+ delegateJniRef = OS.NewGlobalRef(this);
+ if (delegateJniRef is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+ OS.object_setInstanceVariable(this.id, DWT_OBJECT, delegateJniRef);
+ }
+
+ NSArray accessibilityActionNames() {
+
+ if (actionNames !is null)
+ return retainedAutoreleased(actionNames);
+
+ actionNames = accessibleParent.internal_accessibilityActionNames(childID);
+ actionNames.retain();
+ return retainedAutoreleased(actionNames);
+ }
+
+ NSArray accessibilityAttributeNames() {
+
+ if (attributeNames !is null)
+ return retainedAutoreleased(attributeNames);
+
+ attributeNames = accessibleParent.internal_accessibilityAttributeNames(childID);
+ attributeNames.retain();
+ return retainedAutoreleased(attributeNames);
+ }
+
+ id accessibilityAttributeValue(NSString attribute) {
+ return accessibleParent.internal_accessibilityAttributeValue(attribute, childID);
+ }
+
+ // parameterized attribute methods
+ NSArray accessibilityParameterizedAttributeNames() {
+
+ if (parameterizedAttributeNames !is null)
+ return retainedAutoreleased(parameterizedAttributeNames);
+
+ parameterizedAttributeNames = accessibleParent.internal_accessibilityParameterizedAttributeNames(childID);
+ parameterizedAttributeNames.retain();
+ return retainedAutoreleased(parameterizedAttributeNames);
+ }
+
+ id accessibilityAttributeValue_forParameter(NSString attribute, id parameter) {
+ return accessibleParent.internal_accessibilityAttributeValue_forParameter(attribute, parameter, childID);
+ }
+
+ // Return YES if the UIElement doesn't show up to the outside world - i.e. its parent should return the UIElement's children as its own - cutting the UIElement out. E.g. NSControls are ignored when they are single-celled.
+ bool accessibilityIsIgnored() {
+ return accessibleParent.internal_accessibilityIsIgnored(childID);
+ }
+
+ bool accessibilityIsAttributeSettable(NSString attribute) {
+ return accessibleParent.internal_accessibilityIsAttributeSettable(attribute, childID);
+ }
+
+ // Returns the deepest descendant of the UIElement hierarchy that contains the point. You can assume the point has already been determined to lie within the receiver. Override this method to do deeper hit testing within a UIElement - e.g. a NSMatrix would test its cells. The point is bottom-left relative screen coordinates.
+ id accessibilityHitTest(NSPoint point) {
+ return accessibleParent.internal_accessibilityHitTest(point, childID);
+ }
+
+ // Returns the UI Element that has the focus. You can assume that the search for the focus has already been narrowed down to the reciever. Override this method to do a deeper search with a UIElement - e.g. a NSMatrix would determine if one of its cells has the focus.
+ id accessibilityFocusedUIElement() {
+ return accessibleParent.internal_accessibilityFocusedUIElement(childID);
+ }
+
+ void accessibilityPerformAction(NSString action) {
+ accessibleParent.internal_accessibilityPerformAction(action, childID);
+ }
+
+ id accessibilityActionDescription(NSString action) {
+ return accessibleParent.internal_accessibilityActionDescription(action, childID);
+ }
+
+
+ void accessibilitySetValue_forAttribute(id value, NSString attribute) {
+ // This shouldn't be called!
+ System.out.println("Ignoring attribute: " + attribute.getString());
+ }
+
+ static NSArray retainedAutoreleased(NSArray inObject) {
+ id temp = inObject.retain();
+ id temp2 = new NSObject(temp.id).autorelease();
+ return new NSArray(temp2.id);
+ }
+
+ static int /*long*/ accessibleProc(int /*long*/ id, int /*long*/ sel) {
+ SWTAccessibleDelegate swtAcc = getAccessibleDelegate(id);
+ if (swtAcc is null) return 0;
+
+ if (sel is OS.sel_accessibilityAttributeNames) {
+ NSArray retObject = swtAcc.accessibilityAttributeNames();
+ return (retObject is null ? 0 : retObject.id);
+ } else if (sel is OS.sel_accessibilityActionNames) {
+ NSArray retObject = swtAcc.accessibilityActionNames();
+ return (retObject is null ? 0 : retObject.id);
+ } else if (sel is OS.sel_accessibilityParameterizedAttributeNames) {
+ NSArray retObject = swtAcc.accessibilityParameterizedAttributeNames();
+ return (retObject is null ? 0 : retObject.id);
+ } else if (sel is OS.sel_accessibilityIsIgnored) {
+ bool retVal = swtAcc.accessibilityIsIgnored();
+ return (retVal ? 1 : 0);
+ } else if (sel is OS.sel_accessibilityFocusedUIElement) {
+ id retObject = swtAcc.accessibilityFocusedUIElement();
+ return (retObject is null ? 0 : retObject.id);
+ }
+
+ return 0;
+ }
+
+ static int /*long*/ accessibleProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) {
+ SWTAccessibleDelegate swtAcc = getAccessibleDelegate(id);
+ if (swtAcc is null) return 0;
+
+ if (sel is OS.sel_accessibilityAttributeValue_) {
+ NSString attribute = new NSString(arg0);
+ id retObject = swtAcc.accessibilityAttributeValue(attribute);
+ return (retObject is null ? 0 : retObject.id);
+ } else if (sel is OS.sel_accessibilityHitTest_) {
+ NSPoint point= new NSPoint();
+ OS.memmove(point, arg0, NSPoint.sizeof);
+ id retObject = swtAcc.accessibilityHitTest(point);
+ return (retObject is null ? 0 : retObject.id);
+ } else if (sel is OS.sel_accessibilityIsAttributeSettable_) {
+ NSString attribute = new NSString(arg0);
+ return (swtAcc.accessibilityIsAttributeSettable(attribute) ? 1 : 0);
+ } else if (sel is OS.sel_accessibilityActionDescription_) {
+ NSString action = new NSString(arg0);
+ id retObject = swtAcc.accessibilityActionDescription(action);
+ return (retObject is null ? 0 : retObject.id);
+ } else if (sel is OS.sel_accessibilityPerformAction_) {
+ NSString action = new NSString(arg0);
+ swtAcc.accessibilityPerformAction(action);
+ }
+
+ return 0;
+ }
+
+ static int /*long*/ accessibleProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int /*long*/ arg1) {
+ SWTAccessibleDelegate swtAcc = getAccessibleDelegate(id);
+ if (swtAcc is null) return 0;
+
+ if (sel is OS.sel_accessibilityAttributeValue_forParameter_) {
+ NSString attribute = new NSString(arg0);
+ id parameter = new id(arg1);
+ id retObject = swtAcc.accessibilityAttributeValue_forParameter(attribute, parameter);
+ return (retObject is null ? 0 : retObject.id);
+ } else if (sel is OS.sel_accessibilitySetValue_forAttribute_) {
+ id value = new id(arg0);
+ NSString attribute = new NSString(arg1);
+ swtAcc.accessibilitySetValue_forAttribute(value, attribute);
+ }
+
+ return 0;
+ }
+
+ static SWTAccessibleDelegate getAccessibleDelegate(int /*long*/ id) {
+ if (id is 0) return null;
+ int /*long*/ [] jniRef = new int /*long*/ [1];
+ OS.object_getInstanceVariable(id, DWT_OBJECT, jniRef);
+ if (jniRef[0] is 0) return null;
+ return (SWTAccessibleDelegate)OS.JNIGetObject(jniRef[0]);
+ }
+
+ public void internal_dispose_SWTAccessibleDelegate() {
+ if (actionNames !is null) actionNames.release();
+ actionNames = null;
+ if (attributeNames !is null) attributeNames.release();
+ attributeNames = null;
+ if (parameterizedAttributeNames !is null) parameterizedAttributeNames.release();
+ parameterizedAttributeNames = null;
+ }
+
+}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/AppFileLocProvider.d
--- a/dwt/browser/AppFileLocProvider.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/AppFileLocProvider.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/Browser.d
--- a/dwt/browser/Browser.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/Browser.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.Browser;
@@ -51,6 +51,10 @@
* IMPORTANT: This class is not intended to be subclassed.
*
*
+ * @see Browser snippets
+ * @see DWT Examples: ControlExample, BrowserExample
+ * @see Sample code and further information
+ *
* @since 3.0
*/
@@ -456,6 +460,19 @@
public bool forward () {
checkWidget();
return webBrowser.forward();
+}
+
+/**
+ * Returns the type of native browser being used by this instance.
+ * Examples: "mozilla", "ie", "safari", "voyager"
+ *
+ * @return the type of the native browser
+ *
+ * @since 3.5
+ */
+public String getBrowserType () {
+ checkWidget();
+ return webBrowser.getBrowserType ();
}
public int getStyle () {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/CloseWindowListener.d
--- a/dwt/browser/CloseWindowListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/CloseWindowListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.CloseWindowListener;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/Download.d
--- a/dwt/browser/Download.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/Download.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -33,6 +33,12 @@
import dwt.widgets.Listener;
import dwt.widgets.Shell;
+/**
+ * This class implements the nsIDownload interface for mozilla
+ * versions 1.4 - 1.7.x. For mozilla version 1.8.x this interface
+ * is implemented by class nsIDownload_1_8. Later versions of
+ * mozilla do not need to call this interface.
+ */
class Download {
XPCOMObject supports;
XPCOMObject download;
@@ -199,7 +205,7 @@
nsISupports supports = new nsISupports (aTarget);
int /*long*/[] result = new int /*long*/[1];
rc = supports.QueryInterface (nsIURI.NS_IURI_IID, result);
- if (rc is 0) { /* >= 1.7 */
+ if (rc is XPCOM.NS_OK) { /* >= 1.7 */
nsIURI target = new nsIURI (result[0]);
result[0] = 0;
int /*long*/ aPath = XPCOM.nsEmbedCString_new ();
@@ -241,17 +247,17 @@
}
};
shell = new Shell (DWT.DIALOG_TRIM);
- String msg = Compatibility.getMessage ("SWT_Download_File", new Object[] {filename}); //$NON-NLS-1$
+ String msg = Compatibility.getMessage ("DWT_Download_File", new Object[] {filename}); //$NON-NLS-1$
shell.setText (msg);
GridLayout gridLayout = new GridLayout ();
gridLayout.marginHeight = 15;
gridLayout.marginWidth = 15;
gridLayout.verticalSpacing = 20;
shell.setLayout(gridLayout);
- msg = Compatibility.getMessage ("SWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$
+ msg = Compatibility.getMessage ("DWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$
new Label (shell, DWT.SIMPLE).setText (msg);
status = new Label (shell, DWT.SIMPLE);
- msg = Compatibility.getMessage ("SWT_Download_Started"); //$NON-NLS-1$
+ msg = Compatibility.getMessage ("DWT_Download_Started"); //$NON-NLS-1$
status.setText (msg);
GridData data = new GridData ();
data.grabExcessHorizontalSpace = true;
@@ -259,7 +265,7 @@
status.setLayoutData (data);
cancel = new Button (shell, DWT.PUSH);
- cancel.setText (DWT.getMessage ("SWT_Cancel")); //$NON-NLS-1$
+ cancel.setText (DWT.getMessage ("DWT_Cancel")); //$NON-NLS-1$
data = new GridData ();
data.horizontalAlignment = GridData.CENTER;
cancel.setLayoutData (data);
@@ -364,7 +370,7 @@
int totalKBytes = aMaxTotalProgress / 1024;
if (shell !is null && !shell.isDisposed ()) {
Object[] arguments = {new Integer (currentKBytes), new Integer (totalKBytes)};
- String statusMsg = Compatibility.getMessage ("SWT_Download_Status", arguments); //$NON-NLS-1$
+ String statusMsg = Compatibility.getMessage ("DWT_Download_Status", arguments); //$NON-NLS-1$
status.setText (statusMsg);
shell.layout (true);
shell.getDisplay ().update ();
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/DownloadFactory.d
--- a/dwt/browser/DownloadFactory.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/DownloadFactory.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2003, 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/DownloadFactory_1_8.d
--- a/dwt/browser/DownloadFactory_1_8.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/DownloadFactory_1_8.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2003, 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/Download_1_8.d
--- a/dwt/browser/Download_1_8.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/Download_1_8.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -32,6 +32,12 @@
import dwt.widgets.Listener;
import dwt.widgets.Shell;
+/**
+ * This class implements the nsIDownload interface for mozilla
+ * version 1.8.x. For mozilla versions 1.4 - 1.7.x this interface
+ * is implemented by class nsIDownload. Mozilla versions later
+ * than 1.8.x do not need to call this interface.
+ */
class Download_1_8 {
XPCOMObject supports;
XPCOMObject download;
@@ -258,17 +264,17 @@
}
};
shell = new Shell (DWT.DIALOG_TRIM);
- String msg = Compatibility.getMessage ("SWT_Download_File", new Object[] {filename}); //$NON-NLS-1$
+ String msg = Compatibility.getMessage ("DWT_Download_File", new Object[] {filename}); //$NON-NLS-1$
shell.setText (msg);
GridLayout gridLayout = new GridLayout ();
gridLayout.marginHeight = 15;
gridLayout.marginWidth = 15;
gridLayout.verticalSpacing = 20;
shell.setLayout (gridLayout);
- msg = Compatibility.getMessage ("SWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$
+ msg = Compatibility.getMessage ("DWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$
new Label (shell, DWT.SIMPLE).setText (msg);
status = new Label (shell, DWT.SIMPLE);
- msg = Compatibility.getMessage ("SWT_Download_Started"); //$NON-NLS-1$
+ msg = Compatibility.getMessage ("DWT_Download_Started"); //$NON-NLS-1$
status.setText (msg);
GridData data = new GridData ();
data.grabExcessHorizontalSpace = true;
@@ -276,7 +282,7 @@
status.setLayoutData (data);
cancel = new Button (shell, DWT.PUSH);
- cancel.setText (DWT.getMessage ("SWT_Cancel")); //$NON-NLS-1$
+ cancel.setText (DWT.getMessage ("DWT_Cancel")); //$NON-NLS-1$
data = new GridData ();
data.horizontalAlignment = GridData.CENTER;
cancel.setLayoutData (data);
@@ -380,7 +386,7 @@
long totalKBytes = aMaxTotalProgress / 1024;
if (shell !is null && !shell.isDisposed ()) {
Object[] arguments = {new Long (currentKBytes), new Long (totalKBytes)};
- String statusMsg = Compatibility.getMessage ("SWT_Download_Status", arguments); //$NON-NLS-1$
+ String statusMsg = Compatibility.getMessage ("DWT_Download_Status", arguments); //$NON-NLS-1$
status.setText (statusMsg);
shell.layout (true);
shell.getDisplay ().update ();
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/FilePicker.d
--- a/dwt/browser/FilePicker.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/FilePicker.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -18,12 +18,12 @@
import dwt.internal.mozilla.XPCOMObject;
import dwt.internal.mozilla.nsEmbedString;
import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIDOMWindow;
import dwt.internal.mozilla.nsIFilePicker;
import dwt.internal.mozilla.nsIFilePicker_1_8;
import dwt.internal.mozilla.nsILocalFile;
import dwt.internal.mozilla.nsISupports;
import dwt.widgets.DirectoryDialog;
-import dwt.widgets.Display;
import dwt.widgets.FileDialog;
import dwt.widgets.Shell;
@@ -124,6 +124,12 @@
return refCount;
}
+Browser getBrowser (int /*long*/ aDOMWindow) {
+ if (aDOMWindow is 0) return null;
+ nsIDOMWindow window = new nsIDOMWindow (aDOMWindow);
+ return Mozilla.findBrowser (window);
+}
+
/*
* As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type. This method
* answers a java string based on the type of string that is appropriate for the Mozilla
@@ -153,10 +159,12 @@
/* picking a file */
int style = mode is nsIFilePicker.modeSave ? DWT.SAVE : DWT.OPEN;
if (mode is nsIFilePicker.modeOpenMultiple) style |= DWT.MULTI;
- Display display = Display.getCurrent ();
- Shell parent = null; // TODO compute parent
- if (parent is null) {
- parent = new Shell (display);
+ Browser browser = getBrowser (parentHandle);
+ Shell parent = null;
+ if (browser !is null) {
+ parent = browser.getShell ();
+ } else {
+ parent = new Shell ();
}
FileDialog dialog = new FileDialog (parent, style);
if (title !is null) dialog.setText (title);
@@ -174,10 +182,12 @@
}
int showDirectoryPicker () {
- Display display = Display.getCurrent ();
- Shell parent = null; // TODO compute parent
- if (parent is null) {
- parent = new Shell (display);
+ Browser browser = getBrowser (parentHandle);
+ Shell parent = null;
+ if (browser !is null) {
+ parent = browser.getShell ();
+ } else {
+ parent = new Shell ();
}
DirectoryDialog dialog = new DirectoryDialog (parent, DWT.NONE);
if (title !is null) dialog.setText (title);
@@ -226,7 +236,7 @@
}
int GetDisplayDirectory (int /*long*/ aDisplayDirectory) {
- String directoryName = directory !is null ? directory : ""; //$NON-NLS-1$
+ String directoryName = directory !is null ? directory : ""; //$NON-NLS-1$
nsEmbedString path = new nsEmbedString (directoryName);
int /*long*/[] file = new int /*long*/[1];
int rc = XPCOM.NS_NewLocalFile (path.getAddress (), 1, file);
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/FilePickerFactory.d
--- a/dwt/browser/FilePickerFactory.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/FilePickerFactory.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2003, 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/FilePickerFactory_1_8.d
--- a/dwt/browser/FilePickerFactory_1_8.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/FilePickerFactory_1_8.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2003, 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/FilePicker_1_8.d
--- a/dwt/browser/FilePicker_1_8.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/FilePicker_1_8.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2003, 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/HelperAppLauncherDialog.d
--- a/dwt/browser/HelperAppLauncherDialog.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/HelperAppLauncherDialog.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -21,11 +21,16 @@
import dwt.internal.mozilla.nsIHelperAppLauncher;
import dwt.internal.mozilla.nsIHelperAppLauncherDialog;
import dwt.internal.mozilla.nsIHelperAppLauncher_1_8;
-import dwt.internal.mozilla.nsIHelperAppLauncher_1_9;
import dwt.internal.mozilla.nsISupports;
import dwt.widgets.FileDialog;
import dwt.widgets.Shell;
+/**
+ * This class implements the nsIHelperAppLauncherDialog interface for mozilla
+ * versions 1.4 - 1.8.x. For mozilla versions >= 1.9 this interface is
+ * implemented by class HelperAppLauncherDialog_1_9. HelperAppLauncherDialogFactory
+ * determines at runtime which of these classes to instantiate.
+ */
class HelperAppLauncherDialog {
XPCOMObject supports;
XPCOMObject helperAppLauncherDialog;
@@ -109,28 +114,19 @@
int Show (int /*long*/ aLauncher, int /*long*/ aContext, int aReason) {
/*
- * The interface for nsIHelperAppLauncher changed in GRE versions 1.8 and 1.9. Query for
- * each of these interfaces in turn until one is found.
- */
+ * The interface for nsIHelperAppLauncher changed as of mozilla 1.8. Query the received
+ * nsIHelperAppLauncher for the new interface, and if it is not found then fall back to
+ * the old interface.
+ */
nsISupports supports = new nsISupports (aLauncher);
int /*long*/[] result = new int /*long*/[1];
- int rc = supports.QueryInterface (nsIHelperAppLauncher_1_9.NS_IHELPERAPPLAUNCHER_IID, result);
- if (rc is 0) {
- nsIHelperAppLauncher_1_9 helperAppLauncher = new nsIHelperAppLauncher_1_9 (aLauncher);
- rc = helperAppLauncher.SaveToDisk (0, 0);
- helperAppLauncher.Release ();
- return rc;
- }
-
- result[0] = 0;
- rc = supports.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result);
- if (rc is 0) {
+ int rc = supports.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result);
+ if (rc is XPCOM.NS_OK) { /* >= 1.8 */
nsIHelperAppLauncher_1_8 helperAppLauncher = new nsIHelperAppLauncher_1_8 (aLauncher);
rc = helperAppLauncher.SaveToDisk (0, 0);
helperAppLauncher.Release ();
return rc;
}
-
nsIHelperAppLauncher helperAppLauncher = new nsIHelperAppLauncher (aLauncher); /* < 1.8 */
return helperAppLauncher.SaveToDisk (0, 0);
}
@@ -152,28 +148,20 @@
* The interface for nsIHelperAppLauncher changed as of mozilla 1.8, so the first
* argument must be queried for both the old and new nsIHelperAppLauncher interfaces.
*/
- bool using_1_8 = false, using_1_9 = false;
+ bool using_1_8 = false;
nsISupports support = new nsISupports (arg0);
int /*long*/[] result = new int /*long*/[1];
int rc = support.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result);
- if (rc is 0) {
+ if (rc is XPCOM.NS_OK) {
using_1_8 = true;
hasLauncher = true;
new nsISupports (result[0]).Release ();
} else {
result[0] = 0;
- rc = support.QueryInterface (nsIHelperAppLauncher_1_9.NS_IHELPERAPPLAUNCHER_IID, result);
- if (rc is 0) {
- using_1_9 = true;
+ rc = support.QueryInterface (nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result);
+ if (rc is XPCOM.NS_OK) {
hasLauncher = true;
new nsISupports (result[0]).Release ();
- } else {
- result[0] = 0;
- rc = support.QueryInterface (nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result);
- if (rc is 0) {
- hasLauncher = true;
- new nsISupports (result[0]).Release ();
- }
}
}
result[0] = 0;
@@ -209,9 +197,6 @@
if (using_1_8) {
nsIHelperAppLauncher_1_8 launcher = new nsIHelperAppLauncher_1_8 (arg0);
rc = launcher.Cancel (XPCOM.NS_BINDING_ABORTED);
- } else if (using_1_9) {
- nsIHelperAppLauncher_1_9 launcher = new nsIHelperAppLauncher_1_9 (arg0);
- rc = launcher.Cancel (XPCOM.NS_BINDING_ABORTED);
} else {
nsIHelperAppLauncher launcher = new nsIHelperAppLauncher (arg0);
rc = launcher.Cancel ();
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/HelperAppLauncherDialogFactory.d
--- a/dwt/browser/HelperAppLauncherDialogFactory.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/HelperAppLauncherDialogFactory.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2003, 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
@@ -23,6 +23,7 @@
XPCOMObject supports;
XPCOMObject factory;
int refCount = 0;
+ bool isPre_1_9 = true;
this () {
createCOMInterfaces ();
@@ -94,9 +95,15 @@
/* nsIFactory */
int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
- HelperAppLauncherDialog helperAppLauncherDialog = new HelperAppLauncherDialog ();
- helperAppLauncherDialog.AddRef ();
- XPCOM.memmove (result, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF);
+ if (isPre_1_9) {
+ HelperAppLauncherDialog helperAppLauncherDialog = new HelperAppLauncherDialog ();
+ helperAppLauncherDialog.AddRef ();
+ XPCOM.memmove (result, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF);
+ } else {
+ HelperAppLauncherDialog_1_9 helperAppLauncherDialog = new HelperAppLauncherDialog_1_9 ();
+ helperAppLauncherDialog.AddRef ();
+ XPCOM.memmove (result, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF);
+ }
return XPCOM.NS_OK;
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/HelperAppLauncherDialog_1_9.d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/HelperAppLauncherDialog_1_9.d Mon Dec 01 17:07:00 2008 +0100
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.HelperAppLauncherDialog_1_9;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.internal.C;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsEmbedString;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIHelperAppLauncherDialog_1_9;
+import dwt.internal.mozilla.nsIHelperAppLauncher_1_9;
+import dwt.internal.mozilla.nsISupports;
+import dwt.widgets.FileDialog;
+import dwt.widgets.Shell;
+
+/**
+ * This class implements the nsIHelperAppLauncherDialog interface for mozilla
+ * versions >= 1.9. For mozilla versions 1.4 - 1.8.x this interface is
+ * implemented by class HelperAppLauncherDialog. HelperAppLauncherDialogFactory
+ * determines at runtime which of these classes to instantiate.
+ */
+class HelperAppLauncherDialog_1_9 {
+ XPCOMObject supports;
+ XPCOMObject helperAppLauncherDialog;
+ int refCount = 0;
+
+HelperAppLauncherDialog_1_9 () {
+ createCOMInterfaces ();
+}
+
+int AddRef () {
+ refCount++;
+ return refCount;
+}
+
+void createCOMInterfaces () {
+ /* Create each of the interfaces that this object implements */
+ supports = new XPCOMObject (new int[] {2, 0, 0}) {
+ public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+ public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+ public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+ };
+
+ helperAppLauncherDialog = new XPCOMObject (new int[] {2, 0, 0, 3, 6}) {
+ public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+ public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+ public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+ public int /*long*/ method3 (int /*long*/[] args) {return Show (args[0], args[1], (int)/*64*/args[2]);}
+ public int /*long*/ method4 (int /*long*/[] args) {return PromptForSaveToFile (args[0], args[1], args[2], args[3], (int)/*64*/args[4], args[5]);}
+ };
+}
+
+void disposeCOMInterfaces () {
+ if (supports !is null) {
+ supports.dispose ();
+ supports = null;
+ }
+ if (helperAppLauncherDialog !is null) {
+ helperAppLauncherDialog.dispose ();
+ helperAppLauncherDialog = null;
+ }
+}
+
+int /*long*/ getAddress () {
+ return helperAppLauncherDialog.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+ if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+ nsID guid = new nsID ();
+ XPCOM.memmove (guid, riid, nsID.sizeof);
+
+ if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+ XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+ AddRef ();
+ return XPCOM.NS_OK;
+ }
+ if (guid.Equals (nsIHelperAppLauncherDialog_1_9.NS_IHELPERAPPLAUNCHERDIALOG_IID)) {
+ XPCOM.memmove (ppvObject, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF);
+ AddRef ();
+ return XPCOM.NS_OK;
+ }
+
+ XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+ return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int Release () {
+ refCount--;
+ /*
+ * Note. This instance lives as long as the download it is bound to.
+ * Its reference count is expected to go down to 0 when the download
+ * has completed or when it has been cancelled. E.g. when the user
+ * cancels the File Dialog, cancels or closes the Download Dialog
+ * and when the Download Dialog goes away after the download is completed.
+ */
+ if (refCount is 0) disposeCOMInterfaces ();
+ return refCount;
+}
+
+/* nsIHelperAppLauncherDialog */
+
+int Show (int /*long*/ aLauncher, int /*long*/ aContext, int aReason) {
+ nsIHelperAppLauncher_1_9 helperAppLauncher = new nsIHelperAppLauncher_1_9 (aLauncher);
+ return helperAppLauncher.SaveToDisk (0, 0);
+}
+
+int PromptForSaveToFile (int /*long*/ aLauncher, int /*long*/ aWindowContext, int /*long*/ aDefaultFileName, int /*long*/ aSuggestedFileExtension, int aForcePrompt, int /*long*/ _retval) {
+ int length = XPCOM.strlen_PRUnichar (aDefaultFileName);
+ char[] dest = new char[length];
+ XPCOM.memmove (dest, aDefaultFileName, length * 2);
+ String defaultFile = new String (dest);
+
+ length = XPCOM.strlen_PRUnichar (aSuggestedFileExtension);
+ dest = new char[length];
+ XPCOM.memmove (dest, aSuggestedFileExtension, length * 2);
+ String suggestedFileExtension = new String (dest);
+
+ Shell shell = new Shell ();
+ FileDialog fileDialog = new FileDialog (shell, DWT.SAVE);
+ fileDialog.setFileName (defaultFile);
+ fileDialog.setFilterExtensions (new String[] {suggestedFileExtension});
+ String name = fileDialog.open ();
+ shell.close ();
+ if (name is null) {
+ nsIHelperAppLauncher_1_9 launcher = new nsIHelperAppLauncher_1_9 (aLauncher);
+ int rc = launcher.Cancel (XPCOM.NS_BINDING_ABORTED);
+ if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+ return XPCOM.NS_ERROR_FAILURE;
+ }
+ nsEmbedString path = new nsEmbedString (name);
+ int /*long*/[] result = new int /*long*/[1];
+ int rc = XPCOM.NS_NewLocalFile (path.getAddress (), 1, result);
+ path.dispose ();
+ if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+ if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+ /* Our own nsIDownload has been registered during the Browser initialization. It will be invoked by Mozilla. */
+ XPCOM.memmove (_retval, result, C.PTR_SIZEOF);
+ return XPCOM.NS_OK;
+}
+}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/InputStream.d
--- a/dwt/browser/InputStream.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/InputStream.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2003, 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/LocationAdapter.d
--- a/dwt/browser/LocationAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/LocationAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.LocationAdapter;
@@ -26,13 +26,15 @@
* interested in.
*
*
+ * @see Sample code and further information
+ *
* @since 3.0
*/
public abstract class LocationAdapter : LocationListener {
- public void changing (LocationEvent event) {
- }
+public void changing(LocationEvent event) {
+}
- public void changed (LocationEvent event) {
- }
+public void changed(LocationEvent event) {
}
+}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/LocationEvent.d
--- a/dwt/browser/LocationEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/LocationEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.LocationEvent;
@@ -26,6 +26,8 @@
* {@link Browser#setUrl(String)} or when the user activates a
* hyperlink.
*
+ * @see Sample code and further information
+ *
* @since 3.0
*/
public class LocationEvent : TypedEvent {
@@ -46,19 +48,19 @@
static final long serialVersionUID = 3906644198244299574L;
- this (Widget w) {
- super(w);
- }
+this (Widget w) {
+ super(w);
+}
- /**
- * Returns a String containing a concise, human-readable
- * description of the receiver.
- *
- * @return a String representation of the event
- */
- public String toString () {
- String String = super.toString();
- return String.substring(0, String.length() - 1) // remove trailing '}'
- + " location=" + location + " top=" + top + " doit=" + doit + "}";
- }
+/**
+ * Returns a String containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a String representation of the event
+ */
+public String toString () {
+ String str = super.toString();
+ return str.substring(0, str.length() - 1) // remove trailing '}'
+ + " location=" + location + " top=" + top + " doit=" + doit + "}";
}
+}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/LocationListener.d
--- a/dwt/browser/LocationListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/LocationListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.LocationListener;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/Mozilla.d
--- a/dwt/browser/Mozilla.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/Mozilla.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -29,9 +29,7 @@
import dwt.internal.Compatibility;
import dwt.internal.LONG;
import dwt.internal.Library;
-import dwt.internal.mozilla.GREVersionRange;
import dwt.internal.mozilla.XPCOM;
-import dwt.internal.mozilla.XPCOMInit;
import dwt.internal.mozilla.XPCOMObject;
import dwt.internal.mozilla.nsEmbedString;
import dwt.internal.mozilla.nsIAppShell;
@@ -83,6 +81,8 @@
import dwt.internal.mozilla.nsIWebProgress;
import dwt.internal.mozilla.nsIWebProgressListener;
import dwt.internal.mozilla.nsIWindowWatcher;
+import dwt.internal.mozilla.init.GREVersionRange;
+import dwt.internal.mozilla.init.XPCOMInit;
import dwt.layout.FillLayout;
import dwt.widgets.Composite;
import dwt.widgets.Display;
@@ -223,7 +223,7 @@
public void create (Composite parent, int style) {
delegate = new MozillaDelegate (browser);
- Display display = parent.getDisplay ();
+ final Display display = parent.getDisplay ();
int /*long*/[] result = new int /*long*/[1];
if (!Initialized) {
@@ -332,10 +332,37 @@
byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true);
rc = XPCOMInit.XPCOMGlueStartup (path);
if (rc !is XPCOM.NS_OK) {
- IsXULRunner = false; /* failed */
mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf cast(SEPARATOR_OS));
if (Device.DEBUG) System.out.println ("cannot use detected XULRunner: " + mozillaPath); //$NON-NLS-1$
- } else {
+
+ /* attempt to XPCOMGlueStartup the GRE pointed at by MOZILLA_FIVE_HOME */
+ int /*long*/ ptr = C.getenv (MozillaDelegate.wcsToMbcs (null, XPCOM.MOZILLA_FIVE_HOME, true));
+ if (ptr is 0) {
+ IsXULRunner = false;
+ } else {
+ length = C.strlen (ptr);
+ byte[] buffer = new byte[length];
+ C.memmove (buffer, ptr, length);
+ mozillaPath = new String (MozillaDelegate.mbcsToWcs (null, buffer));
+ /*
+ * Attempting to XPCOMGlueStartup a mozilla-based GRE !is xulrunner can
+ * crash, so don't attempt unless the GRE appears to be xulrunner.
+ */
+ if (mozillaPath.indexOf("xulrunner") is -1) { //$NON-NLS-1$
+ IsXULRunner = false;
+ } else {
+ mozillaPath += SEPARATOR_OS + delegate.getLibraryName ();
+ path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true);
+ rc = XPCOMInit.XPCOMGlueStartup (path);
+ if (rc !is XPCOM.NS_OK) {
+ IsXULRunner = false;
+ mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS));
+ if (Device.DEBUG) System.out.println ("failed to start as XULRunner: " + mozillaPath); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ if (IsXULRunner) {
XPCOMInitWasGlued = true;
}
}
@@ -940,17 +967,6 @@
}
factory.Release ();
- HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory ();
- dialogFactory.AddRef ();
- aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true);
- aClassName = MozillaDelegate.wcsToMbcs (null, "Helper App Launcher Dialog", true); //$NON-NLS-1$
- rc = componentRegistrar.RegisterFactory (XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName, aContractID, dialogFactory.getAddress ());
- if (rc !is XPCOM.NS_OK) {
- browser.dispose ();
- error (rc);
- }
- dialogFactory.Release ();
-
/*
* This Download factory will be used if the GRE version is < 1.8.
* If the GRE version is 1.8.x then the Download factory that is registered later for
@@ -1046,7 +1062,17 @@
serviceManager.Release ();
if (XPCOMWasGlued) {
- XPCOM.XPCOMGlueShutdown ();
+ /*
+ * XULRunner 1.9 can crash on Windows if XPCOMGlueShutdown is invoked here,
+ * presumably because one or more of its unloaded symbols are referenced when
+ * this callback returns. The workaround is to delay invoking XPCOMGlueShutdown
+ * so that its symbols are still available once this callback returns.
+ */
+ display.asyncExec (new Runnable () {
+ public void run () {
+ XPCOM.XPCOMGlueShutdown ();
+ }
+ });
XPCOMWasGlued = false;
}
if (XPCOMInitWasGlued) {
@@ -1134,6 +1160,29 @@
if (!PerformedVersionCheck) {
PerformedVersionCheck = true;
+ rc = componentManager.QueryInterface (nsIComponentRegistrar.NS_ICOMPONENTREGISTRAR_IID, result);
+ if (rc !is XPCOM.NS_OK) {
+ browser.dispose ();
+ error (rc);
+ }
+ if (result[0] is 0) {
+ browser.dispose ();
+ error (XPCOM.NS_NOINTERFACE);
+ }
+ nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]);
+ result[0] = 0;
+
+ HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory ();
+ dialogFactory.AddRef ();
+ byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true);
+ byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Helper App Launcher Dialog", true); //$NON-NLS-1$
+ rc = componentRegistrar.RegisterFactory (XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName, aContractID, dialogFactory.getAddress ());
+ if (rc !is XPCOM.NS_OK) {
+ browser.dispose ();
+ error (rc);
+ }
+ dialogFactory.Release ();
+
/*
* Check for the availability of the pre-1.8 implementation of nsIDocShell
* to determine if the GRE's version is < 1.8.
@@ -1171,28 +1220,17 @@
if (rc is XPCOM.NS_OK && result[0] !is 0) { /* 1.8 */
new nsISupports (result[0]).Release ();
result[0] = 0;
- rc = componentManager.QueryInterface (nsIComponentRegistrar.NS_ICOMPONENTREGISTRAR_IID, result);
- if (rc !is XPCOM.NS_OK) {
- browser.dispose ();
- error (rc);
- }
- if (result[0] is 0) {
- browser.dispose ();
- error (XPCOM.NS_NOINTERFACE);
- }
- nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]);
DownloadFactory_1_8 downloadFactory_1_8 = new DownloadFactory_1_8 ();
downloadFactory_1_8.AddRef ();
- byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_TRANSFER_CONTRACTID, true);
- byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Transfer", true); //$NON-NLS-1$
+ aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_TRANSFER_CONTRACTID, true);
+ aClassName = MozillaDelegate.wcsToMbcs (null, "Transfer", true); //$NON-NLS-1$
rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName, aContractID, downloadFactory_1_8.getAddress ());
if (rc !is XPCOM.NS_OK) {
browser.dispose ();
error (rc);
}
downloadFactory_1_8.Release ();
- componentRegistrar.Release ();
} else { /* >= 1.9 */
/*
* Bug in XULRunner 1.9. Mozilla no longer clears its background before initial content has
@@ -1217,10 +1255,13 @@
ABOUT_BLANK.getChars (0, ABOUT_BLANK.length (), uri, 0);
rc = webNavigation.LoadURI (uri, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0);
webNavigation.Release ();
+
+ dialogFactory.isPre_1_9 = false;
}
}
result[0] = 0;
interfaceRequestor.Release ();
+ componentRegistrar.Release ();
}
componentManager.Release ();
@@ -1496,6 +1537,51 @@
return MozillaDelegate.findBrowser (handle);
}
+static Browser findBrowser (nsIDOMWindow aDOMWindow) {
+ int /*long*/[] result = new int /*long*/[1];
+ int rc = XPCOM.NS_GetServiceManager (result);
+ if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+ if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+
+ nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+ result[0] = 0;
+ byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true);
+ rc = serviceManager.GetServiceByContractID (aContractID, nsIWindowWatcher.NS_IWINDOWWATCHER_IID, result);
+ if (rc !is XPCOM.NS_OK) Mozilla.error(rc);
+ if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+ serviceManager.Release ();
+
+ nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]);
+ result[0] = 0;
+ /* the chrome will only be answered for the top-level nsIDOMWindow */
+ rc = aDOMWindow.GetTop (result);
+ if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+ if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+ int /*long*/ topDOMWindow = result[0];
+ result[0] = 0;
+ rc = windowWatcher.GetChromeForWindow (topDOMWindow, result);
+ if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+ if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+ new nsISupports (topDOMWindow).Release ();
+ windowWatcher.Release ();
+
+ nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (result[0]);
+ result[0] = 0;
+ rc = webBrowserChrome.QueryInterface (nsIEmbeddingSiteWindow.NS_IEMBEDDINGSITEWINDOW_IID, result);
+ if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+ if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+ webBrowserChrome.Release ();
+
+ nsIEmbeddingSiteWindow embeddingSiteWindow = new nsIEmbeddingSiteWindow (result[0]);
+ result[0] = 0;
+ rc = embeddingSiteWindow.GetSiteWindow (result);
+ if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+ if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+ embeddingSiteWindow.Release ();
+
+ return findBrowser (result[0]);
+}
+
public bool forward () {
if (awaitingNavigate) return false;
@@ -1511,6 +1597,10 @@
return rc is XPCOM.NS_OK;
}
+public String getBrowserType () {
+ return "mozilla"; //$NON-NLS-1$
+}
+
public String getText () {
if (awaitingNavigate) return ""; //$NON-NLS-1$
@@ -2445,7 +2535,7 @@
int SetWebBrowser (int /*long*/ aWebBrowser) {
if (webBrowser !is null) webBrowser.Release ();
- webBrowser = aWebBrowser !is 0 ? new nsIWebBrowser (aWebBrowser) : null;
+ webBrowser = aWebBrowser !is 0 ? new nsIWebBrowser (aWebBrowser) : null;
return XPCOM.NS_OK;
}
@@ -2803,7 +2893,7 @@
/* First try to use the nsIWebNavigationInfo if it's available (>= mozilla 1.8) */
byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WEBNAVIGATIONINFO_CONTRACTID, true);
rc = serviceManager.GetServiceByContractID (aContractID, nsIWebNavigationInfo.NS_IWEBNAVIGATIONINFO_IID, result);
- if (rc is 0) {
+ if (rc is XPCOM.NS_OK) {
byte[] bytes = MozillaDelegate.wcsToMbcs (null, contentType, true);
int /*long*/ typePtr = XPCOM.nsEmbedCString_new (bytes, bytes.length);
nsIWebNavigationInfo info = new nsIWebNavigationInfo (result[0]);
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/MozillaDelegate.d
--- a/dwt/browser/MozillaDelegate.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/MozillaDelegate.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.MozillaDelegate;
@@ -31,7 +31,7 @@
this.browser = browser;
}
- static Browser findBrowser (int handle) {
+static Browser findBrowser (int /*long*/ handle) {
Display display = Display.getCurrent();
return cast(Browser) display.findWidget(handle);
}
@@ -51,7 +51,7 @@
// OS.CFRelease (cfString);
// }
// return chars;
-
+ // TODO implement mbcsToWcs
//return new String(buffer).toCharArray(); commented by Jacob Carlborg
return cast(char[]) buffer.dup; // FIXME
}
@@ -74,6 +74,7 @@
// OS.CFRelease (cfString);
// }
// return buffer;
+ // TODO implement wcsToMbcs
if (terminate)
str ~= "\0";
@@ -81,7 +82,7 @@
return cast(byte[]) str.dup; // FIXME
}
- int getHandle () {
+int /*long*/ getHandle () {
return browser.view.id;
}
@@ -130,7 +131,7 @@
return false;
}
- void onDispose (int embedHandle) {
+void onDispose (int /*long*/ embedHandle) {
if (listener !is null) {
browser.getDisplay().removeFilter(DWT.FocusIn, listener);
browser.getShell().removeListener(DWT.Deactivate, listener);
@@ -139,7 +140,7 @@
browser = null;
}
- void setSize (int embedHandle, int width, int height) {
+void setSize (int /*long*/ embedHandle, int width, int height) {
// TODO
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/OpenWindowListener.d
--- a/dwt/browser/OpenWindowListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/OpenWindowListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.OpenWindowListener;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/ProgressAdapter.d
--- a/dwt/browser/ProgressAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/ProgressAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.ProgressAdapter;
@@ -26,6 +26,8 @@
* interested in.
*
*
+ * @see Sample code and further information
+ *
* @since 3.0
*/
public abstract class ProgressAdapter : ProgressListener {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/ProgressEvent.d
--- a/dwt/browser/ProgressEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/ProgressEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.ProgressEvent;
@@ -24,6 +24,8 @@
* loading of the current URL or when the loading of the current
* URL has been completed.
*
+ * @see Sample code and further information
+ *
* @since 3.0
*/
public class ProgressEvent : TypedEvent {
@@ -40,14 +42,14 @@
}
/**
- * Returns a String containing a concise, human-readable
+ * Returns a string containing a concise, human-readable
* description of the receiver.
*
- * @return a String representation of the event
+ * @return a string representation of the event
*/
public String toString () {
String str = super.toString();
- return str.substring(0, String.length() - 1) // remove trailing '}'
+ return str.substring(0, str.length() - 1) // remove trailing '}'
+ " current=" + current + " total=" + total + "}";
}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/ProgressListener.d
--- a/dwt/browser/ProgressListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/ProgressListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.ProgressListener;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/PromptDialog.d
--- a/dwt/browser/PromptDialog.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/PromptDialog.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2003, 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
@@ -63,7 +63,7 @@
checkButton.setLayoutData (data);
}
Button okButton = new Button(shell, DWT.PUSH);
- okButton.setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$
+ okButton.setText(DWT.getMessage("DWT_OK")); //$NON-NLS-1$
data = new GridData ();
data.horizontalAlignment = GridData.CENTER;
okButton.setLayoutData (data);
@@ -211,11 +211,11 @@
composite.setLayoutData (data);
composite.setLayout(new GridLayout(2, true));
buttons[1] = new Button(composite, DWT.PUSH);
- buttons[1].setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$
+ buttons[1].setText(DWT.getMessage("DWT_OK")); //$NON-NLS-1$
buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buttons[1].addListener(DWT.Selection, listener);
buttons[2] = new Button(composite, DWT.PUSH);
- buttons[2].setText(DWT.getMessage("SWT_Cancel")); //$NON-NLS-1$
+ buttons[2].setText(DWT.getMessage("DWT_Cancel")); //$NON-NLS-1$
buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buttons[2].addListener(DWT.Selection, listener);
@@ -245,7 +245,7 @@
label.setLayoutData (data);
Label userLabel = new Label(shell, DWT.NONE);
- userLabel.setText(DWT.getMessage("SWT_Username")); //$NON-NLS-1$
+ userLabel.setText(DWT.getMessage("DWT_Username")); //$NON-NLS-1$
final Text userText = new Text(shell, DWT.BORDER);
if (user[0] !is null) userText.setText(user[0]);
@@ -255,7 +255,7 @@
userText.setLayoutData(data);
Label passwordLabel = new Label(shell, DWT.NONE);
- passwordLabel.setText(DWT.getMessage("SWT_Password")); //$NON-NLS-1$
+ passwordLabel.setText(DWT.getMessage("DWT_Password")); //$NON-NLS-1$
final Text passwordText = new Text(shell, DWT.PASSWORD | DWT.BORDER);
if (pass[0] !is null) passwordText.setText(pass[0]);
@@ -288,11 +288,11 @@
composite.setLayoutData (data);
composite.setLayout(new GridLayout(2, true));
buttons[1] = new Button(composite, DWT.PUSH);
- buttons[1].setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$
+ buttons[1].setText(DWT.getMessage("DWT_OK")); //$NON-NLS-1$
buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buttons[1].addListener(DWT.Selection, listener);
buttons[2] = new Button(composite, DWT.PUSH);
- buttons[2].setText(DWT.getMessage("SWT_Cancel")); //$NON-NLS-1$
+ buttons[2].setText(DWT.getMessage("DWT_Cancel")); //$NON-NLS-1$
buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buttons[2].addListener(DWT.Selection, listener);
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/PromptService2.d
--- a/dwt/browser/PromptService2.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/PromptService2.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2003, 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
@@ -22,15 +22,12 @@
import dwt.internal.mozilla.nsIChannel;
import dwt.internal.mozilla.nsID;
import dwt.internal.mozilla.nsIDOMWindow;
-import dwt.internal.mozilla.nsIEmbeddingSiteWindow;
import dwt.internal.mozilla.nsIMemory;
import dwt.internal.mozilla.nsIPromptService;
import dwt.internal.mozilla.nsIPromptService2;
import dwt.internal.mozilla.nsIServiceManager;
import dwt.internal.mozilla.nsISupports;
import dwt.internal.mozilla.nsIURI;
-import dwt.internal.mozilla.nsIWebBrowserChrome;
-import dwt.internal.mozilla.nsIWindowWatcher;
import dwt.widgets.MessageBox;
import dwt.widgets.Shell;
@@ -142,60 +139,19 @@
Browser getBrowser (int /*long*/ aDOMWindow) {
if (aDOMWindow is 0) return null;
-
- int /*long*/[] result = new int /*long*/[1];
- int rc = XPCOM.NS_GetServiceManager (result);
- if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
- if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
-
- nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
- result[0] = 0;
- byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true);
- rc = serviceManager.GetServiceByContractID (aContractID, nsIWindowWatcher.NS_IWINDOWWATCHER_IID, result);
- if (rc !is XPCOM.NS_OK) Mozilla.error(rc);
- if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
- serviceManager.Release ();
-
- nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]);
- result[0] = 0;
- /* the chrome will only be answered for the top-level nsIDOMWindow */
nsIDOMWindow window = new nsIDOMWindow (aDOMWindow);
- rc = window.GetTop (result);
- if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
- if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
- aDOMWindow = result[0];
- result[0] = 0;
- rc = windowWatcher.GetChromeForWindow (aDOMWindow, result);
- if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
- if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
- windowWatcher.Release ();
-
- nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (result[0]);
- result[0] = 0;
- rc = webBrowserChrome.QueryInterface (nsIEmbeddingSiteWindow.NS_IEMBEDDINGSITEWINDOW_IID, result);
- if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
- if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
- webBrowserChrome.Release ();
-
- nsIEmbeddingSiteWindow embeddingSiteWindow = new nsIEmbeddingSiteWindow (result[0]);
- result[0] = 0;
- rc = embeddingSiteWindow.GetSiteWindow (result);
- if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
- if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
- embeddingSiteWindow.Release ();
-
- return Mozilla.findBrowser (result[0]);
+ return Mozilla.findBrowser (window);
}
String getLabel (int buttonFlag, int index, int /*long*/ buttonTitle) {
String label = null;
int flag = (buttonFlag & (0xff * index)) / index;
switch (flag) {
- case nsIPromptService.BUTTON_TITLE_CANCEL : label = DWT.getMessage ("SWT_Cancel"); break; //$NON-NLS-1$
- case nsIPromptService.BUTTON_TITLE_NO : label = DWT.getMessage ("SWT_No"); break; //$NON-NLS-1$
- case nsIPromptService.BUTTON_TITLE_OK : label = DWT.getMessage ("SWT_OK"); break; //$NON-NLS-1$
- case nsIPromptService.BUTTON_TITLE_SAVE : label = DWT.getMessage ("SWT_Save"); break; //$NON-NLS-1$
- case nsIPromptService.BUTTON_TITLE_YES : label = DWT.getMessage ("SWT_Yes"); break; //$NON-NLS-1$
+ case nsIPromptService.BUTTON_TITLE_CANCEL : label = DWT.getMessage ("DWT_Cancel"); break; //$NON-NLS-1$
+ case nsIPromptService.BUTTON_TITLE_NO : label = DWT.getMessage ("DWT_No"); break; //$NON-NLS-1$
+ case nsIPromptService.BUTTON_TITLE_OK : label = DWT.getMessage ("DWT_OK"); break; //$NON-NLS-1$
+ case nsIPromptService.BUTTON_TITLE_SAVE : label = DWT.getMessage ("DWT_Save"); break; //$NON-NLS-1$
+ case nsIPromptService.BUTTON_TITLE_YES : label = DWT.getMessage ("DWT_Yes"); break; //$NON-NLS-1$
case nsIPromptService.BUTTON_TITLE_IS_STRING : {
int length = XPCOM.strlen_PRUnichar (buttonTitle);
char[] dest = new char[length];
@@ -420,7 +376,7 @@
int[] checkValue = new int[1];
String[] userLabel = new String[1], passLabel = new String[1];
- String title = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$
+ String title = DWT.getMessage ("DWT_Authentication_Required"); //$NON-NLS-1$
if (checkboxLabel !is 0 && checkboxValue !is 0) {
int length = XPCOM.strlen_PRUnichar (checkboxLabel);
@@ -486,7 +442,7 @@
String message;
if (realm.length () > 0 && host.length () > 0) {
- message = Compatibility.getMessage ("SWT_Enter_Username_and_Password", new String[] {realm, host}); //$NON-NLS-1$
+ message = Compatibility.getMessage ("DWT_Enter_Username_and_Password", new String[] {realm, host}); //$NON-NLS-1$
} else {
message = ""; //$NON-NLS-1$
}
@@ -526,7 +482,7 @@
XPCOM.memmove (dest, aDialogTitle, length * 2);
titleLabel = new String (dest);
} else {
- titleLabel = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$
+ titleLabel = DWT.getMessage ("DWT_Authentication_Required"); //$NON-NLS-1$
}
length = XPCOM.strlen_PRUnichar (aText);
@@ -564,7 +520,7 @@
Shell shell = browser is null ? new Shell () : browser.getShell ();
PromptDialog dialog = new PromptDialog (shell);
int[] check = new int[1], result = new int[1];
- if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4); /* PRBool */
+ if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4); /* PRBool */
dialog.promptUsernameAndPassword (titleLabel, textLabel, checkLabel, userLabel, passLabel, check, result);
XPCOM.memmove (_retval, result, 4); /* PRBool */
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/PromptService2Factory.d
--- a/dwt/browser/PromptService2Factory.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/PromptService2Factory.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2003, 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/Safari.d
--- a/dwt/browser/Safari.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/Safari.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -7,37 +7,31 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
*******************************************************************************/
module dwt.browser.Safari;
+import dwt.dwthelper.utils;
+
import dwt.DWT;
-import dwt.browser.LocationEvent;
-import dwt.browser.ProgressEvent;
-import dwt.browser.ProgressListener;
-import dwt.browser.StatusTextEvent;
-import dwt.browser.TitleEvent;
-import dwt.browser.TitleListener;
-import dwt.browser.WebBrowser;
-import dwt.dwthelper.utils;
import dwt.graphics.Point;
import dwt.graphics.Rectangle;
+import dwt.internal.C;
import dwt.internal.Callback;
+import dwt.internal.Compatibility;
import dwt.internal.cocoa.DOMDocument;
-import dwt.internal.cocoa.DOMEvent;
import dwt.internal.cocoa.DOMKeyboardEvent;
import dwt.internal.cocoa.DOMMouseEvent;
import dwt.internal.cocoa.DOMWheelEvent;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSError;
import dwt.internal.cocoa.NSHTTPCookie;
import dwt.internal.cocoa.NSHTTPCookieStorage;
import dwt.internal.cocoa.NSNotificationCenter;
import dwt.internal.cocoa.NSNumber;
import dwt.internal.cocoa.NSPrintInfo;
import dwt.internal.cocoa.NSPrintOperation;
+import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSURL;
import dwt.internal.cocoa.NSURLDownload;
@@ -53,7 +47,6 @@
import dwt.internal.cocoa.WebPreferences;
import dwt.internal.cocoa.WebView;
import dwt.internal.cocoa.id;
-
import dwt.widgets.Composite;
import dwt.widgets.Display;
import dwt.widgets.Event;
@@ -62,65 +55,57 @@
import dwt.widgets.Menu;
import dwt.widgets.MessageBox;
import dwt.widgets.Shell;
-
-import Math = tango.math.Math;
-
-import dwt.dwthelper.Runnable;
+import dwt.widgets.Widget;
-class Safari : WebBrowser
-{
+class Safari extends WebBrowser {
WebView webView;
- DWTWebViewDelegate delegatee;
- int jniRef;
+ SWTWebViewDelegate delegate;
bool changingLocation;
String lastHoveredLinkURL;
String html;
- int identifier;
+ int /*long*/ identifier;
int resourceCount;
- String url = "";
+ String url = ""; //$NON-NLS-1$
Point location;
Point size;
bool statusBar = true, toolBar = true, ignoreDispose;
int lastMouseMoveX, lastMouseMoveY;
//TEMPORARY CODE
- // bool doit;
+// bool doit;
static bool Initialized;
- static Callback Callback2, Callback3, Callback4, Callback5, Callback6, Callback7;
-
- static const int MIN_SIZE = 16;
- static const int MAX_PROGRESS = 100;
- static const String WebElementLinkURLKey = "WebElementLinkURL"; //$NON-NLS-1$
- static const String AGENT_STRING = "Safari/unknown"; //$NON-NLS-1$
- static const String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$
- static const String PROTOCOL_FILE = "file:"; //$NON-NLS-1$
- static const String PROTOCOL_HTTP = "http:"; //$NON-NLS-1$
- static const String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
- static const String SAFARI_EVENTS_FIX_KEY = "dwt.internal.safariEventsFix"; //$NON-NLS-1$
+ // the following Callbacks are never freed
+ static Callback Callback3, Callback4, Callback5, Callback6, Callback7;
- /* event Strings */
- static const String DOMEVENT_KEYUP = "keyup"; //$NON-NLS-1$
- static const String DOMEVENT_KEYDOWN = "keydown"; //$NON-NLS-1$
- static const String DOMEVENT_MOUSEDOWN = "mousedown"; //$NON-NLS-1$
- static const String DOMEVENT_MOUSEUP = "mouseup"; //$NON-NLS-1$
- static const String DOMEVENT_MOUSEMOVE = "mousemove"; //$NON-NLS-1$
- static const String DOMEVENT_MOUSEWHEEL = "mousewheel"; //$NON-NLS-1$
+ static final int MIN_SIZE = 16;
+ static final int MAX_PROGRESS = 100;
+ static final String WebElementLinkURLKey = "WebElementLinkURL"; //$NON-NLS-1$
+ static final String AGENT_STRING = "Safari/unknown"; //$NON-NLS-1$
+ static final String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$
+ static final String PROTOCOL_FILE = "file://"; //$NON-NLS-1$
+ static final String PROTOCOL_HTTP = "http://"; //$NON-NLS-1$
+ static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
+ static final String ADD_WIDGET_KEY = "dwt.internal.addWidget"; //$NON-NLS-1$
+ static final String SAFARI_EVENTS_FIX_KEY = "dwt.internal.safariEventsFix"; //$NON-NLS-1$
+ static final String DWT_OBJECT = "DWT_OBJECT"; //$NON-NLS-1$
- static this ()
- {
- NativeClearSessions = new class Runnable
- {
- public void run ()
- {
+ /* event strings */
+ static final String DOMEVENT_KEYUP = "keyup"; //$NON-NLS-1$
+ static final String DOMEVENT_KEYDOWN = "keydown"; //$NON-NLS-1$
+ static final String DOMEVENT_MOUSEDOWN = "mousedown"; //$NON-NLS-1$
+ static final String DOMEVENT_MOUSEUP = "mouseup"; //$NON-NLS-1$
+ static final String DOMEVENT_MOUSEMOVE = "mousemove"; //$NON-NLS-1$
+ static final String DOMEVENT_MOUSEWHEEL = "mousewheel"; //$NON-NLS-1$
+
+ static {
+ NativeClearSessions = new Runnable() {
+ public void run() {
NSHTTPCookieStorage storage = NSHTTPCookieStorage.sharedHTTPCookieStorage();
NSArray cookies = storage.cookies();
- int count = cookies.count();
-
- for (int i = 0; i < count; i++)
- {
+ int /*long*/ count = cookies.count();
+ for (int i = 0; i < count; i++) {
NSHTTPCookie cookie = new NSHTTPCookie(cookies.objectAtIndex(i));
- if (cookie.isSessionOnly())
- {
+ if (cookie.isSessionOnly()) {
storage.deleteCookie(cookie);
}
}
@@ -128,1439 +113,1134 @@
};
}
- public void create (Composite parent, int style)
- {
-
- String className = "DWTWebViewDelegate";
- if (OS.objc_lookUpClass(className) == 0)
- {
- ClassInfo safaryClass = this.classinfo;
- Callback2 = new Callback(safaryClass, "browserProc", 2);
- int proc2 = Callback2.getAddress();
- if (proc2 is 0)
- DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
- Callback3 = new Callback(safaryClass, "browserProc", 3);
- int proc3 = Callback3.getAddress();
- if (proc3 is 0)
- DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
- Callback4 = new Callback(safaryClass, "browserProc", 4);
- int proc4 = Callback4.getAddress();
- if (proc4 is 0)
- DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
- Callback5 = new Callback(safaryClass, "browserProc", 5);
- int proc5 = Callback5.getAddress();
- if (proc5 is 0)
- DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
- Callback6 = new Callback(safaryClass, "browserProc", 6);
- int proc6 = Callback6.getAddress();
- if (proc6 is 0)
- DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
- Callback7 = new Callback(safaryClass, "browserProc", 7);
- int proc7 = Callback7.getAddress();
- if (proc7 is 0)
- DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
-
- int cls = OS.objc_allocateClassPair(OS.class_WebView, className, 0);
- OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte) (Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
- OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
- OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
- OS.class_addMethod(cls, OS.sel_webView_1didChangeLocationWithinPageForFrame_1, proc4, "@:@@");
- OS.class_addMethod(cls, OS.sel_webView_1didFailProvisionalLoadWithError_1forFrame_1, proc5, "@:@@@");
- OS.class_addMethod(cls, OS.sel_webView_1didFinishLoadForFrame_1, proc4, "@:@@");
- OS.class_addMethod(cls, OS.sel_webView_1didReceiveTitle_1forFrame_1, proc5, "@:@@@");
- OS.class_addMethod(cls, OS.sel_webView_1didStartProvisionalLoadForFrame_1, proc4, "@:@@");
- OS.class_addMethod(cls, OS.sel_webView_1didCommitLoadForFrame_1, proc4, "@:@@");
- OS.class_addMethod(cls, OS.sel_webView_1resource_1didFinishLoadingFromDataSource_1, proc5, "@:@@@");
- OS.class_addMethod(cls, OS.sel_webView_1resource_1didFailLoadingWithError_1fromDataSource_1, proc6, "@:@@@@");
- OS.class_addMethod(cls, OS.sel_webView_1identifierForInitialRequest_1fromDataSource_1, proc5, "@:@@@");
- OS.class_addMethod(cls, OS.sel_webView_1resource_1willSendRequest_1redirectResponse_1fromDataSource_1, proc7, "@:@@@@@");
- OS.class_addMethod(cls, OS.sel_handleNotification_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_webView_1createWebViewWithRequest_1, proc4, "@:@@");
- OS.class_addMethod(cls, OS.sel_webViewShow_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_webView_1setFrame_1, proc4, "@:@@");
- OS.class_addMethod(cls, OS.sel_webViewClose_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_webView_1contextMenuItemsForElement_1defaultMenuItems_1, proc5, "@:@@@");
- OS.class_addMethod(cls, OS.sel_webView_1setStatusBarVisible_1, proc4, "@:@B");
- OS.class_addMethod(cls, OS.sel_webView_1setResizable_1, proc4, "@:@B");
- OS.class_addMethod(cls, OS.sel_webView_1setToolbarsVisible_1, proc4, "@:@B");
- OS.class_addMethod(cls, OS.sel_webView_1setStatusText_1, proc4, "@:@@");
- OS.class_addMethod(cls, OS.sel_webViewFocus_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_webViewUnfocus_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_webView_1runJavaScriptAlertPanelWithMessage_1, proc4, "@:@@");
- OS.class_addMethod(cls, OS.sel_webView_1runJavaScriptConfirmPanelWithMessage_1, proc4, "@:@@");
- OS.class_addMethod(cls, OS.sel_webView_1runOpenPanelForFileButtonWithResultListener_1, proc4, "@:@@");
- OS.class_addMethod(cls, OS.sel_webView_1mouseDidMoveOverElement_1modifierFlags_1, proc5, "@:@@I");
- OS.class_addMethod(cls, OS.sel_webView_1printFrameView_1, proc4, "@:@@");
- OS.class_addMethod(cls, OS.sel_webView_1decidePolicyForMIMEType_1request_1frame_1decisionListener_1, proc7, "@:@@@@@");
- OS.class_addMethod(cls, OS.sel_webView_1decidePolicyForNavigationAction_1request_1frame_1decisionListener_1, proc7, "@:@@@@@");
- OS.class_addMethod(cls, OS.sel_webView_1decidePolicyForNewWindowAction_1request_1newFrameName_1decisionListener_1, proc7, "@:@@@@@");
- OS.class_addMethod(cls, OS.sel_webView_1unableToImplementPolicyWithError_1frame_1, proc5, "@:@@@");
- OS.class_addMethod(cls, OS.sel_download_1decideDestinationWithSuggestedFilename_1, proc4, "@:@@");
- OS.class_addMethod(cls, OS.sel_handleEvent_1, proc3, "@:@");
- OS.objc_registerClassPair(cls);
- }
-
- /*
- * Override the default event mechanism to not send key events so
- * that the browser can send them by listening to the DOM instead.
- */
- browser.setData(SAFARI_EVENTS_FIX_KEY);
-
- WebView webView = cast(WebView) (new WebView()).alloc();
- if (webView is null)
- DWT.error(DWT.ERROR_NO_HANDLES);
- webView.initWithFrame(browser.view.frame(), null, null);
- webView.setAutoresizingMask(OS.NSViewWidthSizable | OS.NSViewHeightSizable);
- jniRef = OS.NewGlobalRef(this);
- if (jniRef is 0)
- DWT.error(DWT.ERROR_NO_HANDLES);
- const DWTWebViewDelegate delegatee = cast(DWTWebViewDelegate) (new DWTWebViewDelegate()).alloc().init();
- delegatee.setTag(jniRef);
- this.delegatee = delegatee;
- this.webView = webView;
- browser.view.addSubview_(webView);
-
- const NSNotificationCenter notificationCenter = NSNotificationCenter.defaultCenter();
+public void create (Composite parent, int style) {
+ String className = "SWTWebViewDelegate"; //$NON-NLS-1$
+ if (OS.objc_lookUpClass(className) is 0) {
+ Class safariClass = this.getClass();
+ Callback3 = new Callback(safariClass, "browserProc", 3); //$NON-NLS-1$
+ int /*long*/ proc3 = Callback3.getAddress();
+ if (proc3 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+ Callback4 = new Callback(safariClass, "browserProc", 4); //$NON-NLS-1$
+ int /*long*/ proc4 = Callback4.getAddress();
+ if (proc4 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+ Callback5 = new Callback(safariClass, "browserProc", 5); //$NON-NLS-1$
+ int /*long*/ proc5 = Callback5.getAddress();
+ if (proc5 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+ Callback6 = new Callback(safariClass, "browserProc", 6); //$NON-NLS-1$
+ int /*long*/ proc6 = Callback6.getAddress();
+ if (proc6 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+ Callback7 = new Callback(safariClass, "browserProc", 7); //$NON-NLS-1$
+ int /*long*/ proc7 = Callback7.getAddress();
+ if (proc7 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+ int /*long*/ setFrameProc = OS.webView_setFrame_CALLBACK(proc4);
+ if (setFrameProc is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
- Listener listener = new class (notificationCenter) Listener
- {
- NSNotificationCenter notificationCenter;
-
- this (NSNotificationCenter notificationCenter)
- {
- this.notificationCenter = notificationCenter;
- }
-
- public void handleEvent (Event e)
- {
- switch (e.type)
- {
- case DWT.Dispose:
- {
- /* make this handler run after other dispose listeners */
- if (ignoreDispose)
- {
- ignoreDispose = false;
- break;
- }
- ignoreDispose = true;
- browser.notifyListeners(e.type, e);
- e.type = DWT.NONE;
-
- webView.setFrameLoadDelegate(null);
- webView.setResourceLoadDelegate(null);
- webView.setUIDelegate(null);
- webView.setPolicyDelegate(null);
- webView.setDownloadDelegate(null);
- notificationCenter.removeObserver(delegatee);
-
- webView.release();
- webView = null;
- delegatee.release();
- delegatee = null;
- OS.DeleteGlobalRef(jniRef);
- jniRef = 0;
- html = null;
- lastHoveredLinkURL = null;
- break;
- }
- }
- }
- };
- browser.addListener(DWT.Dispose, listener);
-
- webView.setFrameLoadDelegate(delegatee);
- webView.setResourceLoadDelegate(delegatee);
- webView.setUIDelegate(delegatee);
- notificationCenter.addObserver(delegatee, OS.sel_handleNotification_1, null, webView);
- webView.setPolicyDelegate(delegatee);
- webView.setDownloadDelegate(delegatee);
- webView.setApplicationNameForUserAgent(NSString.StringWith(AGENT_STRING));
-
- if (!Initialized)
- {
- Initialized = true;
- /* disable applets */
- WebPreferences.standardPreferences().setJavaEnabled(false);
- }
- }
-
- public bool back ()
- {
- html = null;
- return webView.goBack();
- }
-
- static int browserProc (int delegatee, int sel)
- {
- if (sel is OS.sel_tag)
- {
- int[] tag = new int[1];
- OS.object_getInstanceVariable(delegatee, "tag", tag);
- return tag[0];
- }
- return 0;
- }
-
- static int browserProc (int id, int sel, int arg0)
- {
- if (sel is OS.sel_setTag_1)
- {
- OS.object_setInstanceVariable(id, "tag", arg0);
- return 0;
- }
- int jniRef = OS.objc_msgSend(id, OS.sel_tag);
- if (jniRef is 0 || jniRef is -1)
- return 0;
- Safari widget = cast(Safari) OS.JNIGetObject(jniRef);
- if (widget is null)
- return 0;
- if (sel is OS.sel_handleNotification_1)
- {
- widget.handleNotification(arg0);
- }
- else if (sel is OS.sel_webViewShow_1)
- {
- widget.webViewShow(arg0);
- }
- else if (sel is OS.sel_webViewClose_1)
- {
- widget.webViewClose(arg0);
- }
- else if (sel is OS.sel_webViewFocus_1)
- {
- widget.webViewFocus(arg0);
- }
- else if (sel is OS.sel_webViewUnfocus_1)
- {
- widget.webViewUnfocus(arg0);
- }
- else if (sel is OS.sel_handleEvent_1)
- {
- widget.handleEvent(arg0);
- }
- return 0;
- }
+ String types = "*"; //$NON-NLS-1$
+ int size = C.PTR_SIZEOF, align = C.PTR_SIZEOF is 4 ? 2 : 3;
- static int browserProc (int id, int sel, int arg0, int arg1)
- {
- if (sel is OS.sel_setTag_1)
- {
- OS.object_setInstanceVariable(id, "tag", arg0);
- return 0;
- }
- int jniRef = OS.objc_msgSend(id, OS.sel_tag);
- if (jniRef is 0 || jniRef is -1)
- return 0;
- Safari widget = cast(Safari) OS.JNIGetObject(jniRef);
- if (widget is null)
- return 0;
- if (sel is OS.sel_webView_1didChangeLocationWithinPageForFrame_1)
- {
- widget.webView_didChangeLocationWithinPageForFrame(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1didFinishLoadForFrame_1)
- {
- widget.webView_didFinishLoadForFrame(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1didStartProvisionalLoadForFrame_1)
- {
- widget.webView_didStartProvisionalLoadForFrame(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1didCommitLoadForFrame_1)
- {
- widget.webView_didCommitLoadForFrame(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1setFrame_1)
- {
- widget.webView_setFrame(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1createWebViewWithRequest_1)
- {
- return widget.webView_createWebViewWithRequest(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1setStatusBarVisible_1)
- {
- widget.webView_setStatusBarVisible(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1setResizable_1)
- {
- widget.webView_setResizable(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1setStatusText_1)
- {
- widget.webView_setStatusText(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1setToolbarsVisible_1)
- {
- widget.webView_setToolbarsVisible(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1runJavaScriptAlertPanelWithMessage_1)
- {
- widget.webView_runJavaScriptAlertPanelWithMessage(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1runJavaScriptConfirmPanelWithMessage_1)
- {
- return widget.webView_runJavaScriptConfirmPanelWithMessage(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1runOpenPanelForFileButtonWithResultListener_1)
- {
- widget.webView_runOpenPanelForFileButtonWithResultListener(arg0, arg1);
- }
- else if (sel is OS.sel_download_1decideDestinationWithSuggestedFilename_1)
- {
- widget.download_decideDestinationWithSuggestedFilename(arg0, arg1);
- }
- else if (sel is OS.sel_webView_1printFrameView_1)
- {
- widget.webView_printFrameView(arg0, arg1);
- }
- return 0;
- }
-
- static int browserProc (int id, int sel, int arg0, int arg1, int arg2)
- {
- int jniRef = OS.objc_msgSend(id, OS.sel_tag);
- if (jniRef is 0 || jniRef is -1)
- return 0;
- Safari widget = cast(Safari) OS.JNIGetObject(jniRef);
- if (widget is null)
- return 0;
- if (sel is OS.sel_webView_1didFailProvisionalLoadWithError_1forFrame_1)
- {
- widget.webView_didFailProvisionalLoadWithError_forFrame(arg0, arg1, arg2);
- }
- else if (sel is OS.sel_webView_1didReceiveTitle_1forFrame_1)
- {
- widget.webView_didReceiveTitle_forFrame(arg0, arg1, arg2);
- }
- else if (sel is OS.sel_webView_1resource_1didFinishLoadingFromDataSource_1)
- {
- widget.webView_resource_didFinishLoadingFromDataSource(arg0, arg1, arg2);
- }
- else if (sel is OS.sel_webView_1identifierForInitialRequest_1fromDataSource_1)
- {
- return widget.webView_identifierForInitialRequest_fromDataSource(arg0, arg1, arg2);
- }
- else if (sel is OS.sel_webView_1contextMenuItemsForElement_1defaultMenuItems_1)
- {
- return widget.webView_contextMenuItemsForElement_defaultMenuItems(arg0, arg1, arg2);
- }
- else if (sel is OS.sel_webView_1mouseDidMoveOverElement_1modifierFlags_1)
- {
- widget.webView_mouseDidMoveOverElement_modifierFlags(arg0, arg1, arg2);
- }
- else if (sel is OS.sel_webView_1unableToImplementPolicyWithError_1frame_1)
- {
- widget.webView_unableToImplementPolicyWithError_frame(arg0, arg1, arg2);
- }
- return 0;
- }
-
- static int browserProc (int id, int sel, int arg0, int arg1, int arg2, int arg3)
- {
- int jniRef = OS.objc_msgSend(id, OS.sel_tag);
- if (jniRef is 0 || jniRef is -1)
- return 0;
- Safari widget = cast(Safari) OS.JNIGetObject(jniRef);
- if (widget is null)
- return 0;
- if (sel is OS.sel_webView_1resource_1didFailLoadingWithError_1fromDataSource_1)
- {
- widget.webView_resource_didFailLoadingWithError_fromDataSource(arg0, arg1, arg2, arg3);
- }
- return 0;
- }
-
- static int browserProc (int id, int sel, int arg0, int arg1, int arg2, int arg3, int arg4)
- {
- int jniRef = OS.objc_msgSend(id, OS.sel_tag);
- if (jniRef is 0 || jniRef is -1)
- return 0;
- Safari widget = cast(Safari) OS.JNIGetObject(jniRef);
- if (widget is null)
- return 0;
- if (sel is OS.sel_webView_1resource_1willSendRequest_1redirectResponse_1fromDataSource_1)
- {
- return widget.webView_resource_willSendRequest_redirectResponse_fromDataSource(arg0, arg1, arg2, arg3, arg4);
- }
- else if (sel is OS.sel_webView_1decidePolicyForMIMEType_1request_1frame_1decisionListener_1)
- {
- widget.webView_decidePolicyForMIMEType_request_frame_decisionListener(arg0, arg1, arg2, arg3, arg4);
- }
- else if (sel is OS.sel_webView_1decidePolicyForNavigationAction_1request_1frame_1decisionListener_1)
- {
- widget.webView_decidePolicyForNavigationAction_request_frame_decisionListener(arg0, arg1, arg2, arg3, arg4);
- }
- else if (sel is OS.sel_webView_1decidePolicyForNewWindowAction_1request_1newFrameName_1decisionListener_1)
- {
- widget.webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener(arg0, arg1, arg2, arg3, arg4);
- }
- return 0;
- }
-
- public bool execute (String script)
- {
- return webView.StringByEvaluatingJavaScriptFromString(NSString.StringWith(script)) !is null;
- }
-
- public bool forward ()
- {
- html = null;
- return webView.goForward();
- }
-
- public String getText ()
- {
- WebFrame mainFrame = webView.mainFrame();
- WebDataSource dataSource = mainFrame.dataSource();
- if (dataSource is null)
- return ""; //$NON-NLS-1$
- WebDocumentRepresentation representation = dataSource.representation();
- if (representation is null)
- return ""; //$NON-NLS-1$
- NSString source = representation.documentSource();
- if (source is null)
- return ""; //$NON-NLS-1$
- char[] buffer = new char[source.length()];
- source.getCharacters_(buffer);
- return new String(buffer);
- }
-
- public String getUrl ()
- {
- return url;
- }
-
- public bool isBackEnabled ()
- {
- return webView.canGoBack();
- }
-
- public bool isForwardEnabled ()
- {
- return webView.canGoForward();
- }
-
- public void refresh ()
- {
- webView.reload(null);
- }
-
- public bool setText (String html)
- {
- /*
- * Bug in Safari. The web view segment faults in some circumstances
- * when the text changes during the location changing callback. The
- * fix is to defer the work until the callback is done.
- */
- if (changingLocation)
- {
- this.html = html;
- }
- else
- {
- _setText(html);
- }
- return true;
- }
-
- void _setText (String html)
- {
- NSString String = NSString.StringWith(html);
- NSString URLString = NSString.StringWith(URI_FROMMEMORY);
- NSURL URL = NSURL.static_URLWithString_(URLString);
- WebFrame mainFrame = webView.mainFrame();
- mainFrame.loadHTMLString(String, URL);
- }
-
- public bool setUrl (String url)
- {
- html = null;
-
- NSURL inURL;
- if (url.startsWith(PROTOCOL_FILE))
- {
- url = url.substring(PROTOCOL_FILE.length());
- }
- bool isHttpURL = url.indexOf('/') !is 0;
- if (isHttpURL)
- {
- if (url.indexOf(':') is -1)
- {
- url = PROTOCOL_HTTP + "//" + url; //$NON-NLS-1$
- }
- inURL = NSURL.static_URLWithString_(NSString.StringWith(url.toString()));
- }
- else
- {
- inURL = NSURL.static_fileURLWithPath_(NSString.StringWith(url.toString()));
- }
- if (inURL is null)
- return false;
-
- NSURLRequest request = NSURLRequest.static_requestWithURL_(inURL);
- WebFrame mainFrame = webView.mainFrame();
- mainFrame.loadRequest(request);
- return true;
- }
-
- public void stop ()
- {
- html = null;
- webView.stopLoading(null);
- }
-
- /* WebFrameLoadDelegate */
-
- void webView_didChangeLocationWithinPageForFrame (int sender, int frameID)
- {
- WebFrame frame = new WebFrame(frameID);
- WebDataSource dataSource = frame.dataSource();
- NSURLRequest request = dataSource.request();
- NSURL url = request.URL();
- NSString s = url.absoluteString();
- int length = s.length();
- if (length is 0)
- return;
- char[] buffer = new char[length];
- s.getCharacters_(buffer);
- String url2 = new String(buffer);
- /*
- * If the URI indicates that the page is being rendered from memory
- * (via setText()) then set it to about:blank to be consistent with IE.
- */
- if (url2.opEquals(URI_FROMMEMORY))
- url2 = ABOUT_BLANK;
-
- const Display display = browser.getDisplay();
- bool top = frameID is webView.mainFrame().id;
- if (top)
- {
- StatusTextEvent statusText = new StatusTextEvent(browser);
- statusText.display = display;
- statusText.widget = browser;
- statusText.text = url2;
- for (int i = 0; i < statusTextListeners.length; i++)
- {
- statusTextListeners[i].changed(statusText);
- }
- }
-
- LocationEvent location = new LocationEvent(browser);
- location.display = display;
- location.widget = browser;
- location.location = url2;
- location.top = top;
- for (int i = 0; i < locationListeners.length; i++)
- {
- locationListeners[i].changed(location);
- }
- }
-
- void webView_didFailProvisionalLoadWithError_forFrame (int sender, int error, int frame)
- {
- if (frame is webView.mainFrame().id)
- {
- /*
- * Feature on Safari. The identifier is used here as a marker for the events
- * related to the top frame and the URL changes related to that top frame as
- * they should appear on the location bar of a browser. It is expected to reset
- * the identifier to 0 when the event didFinishLoadingFromDataSource related to
- * the identifierForInitialRequest event is received. However, Safari fires
- * the didFinishLoadingFromDataSource event before the entire content of the
- * top frame is loaded. It is possible to receive multiple willSendRequest
- * events in this interval, causing the Browser widget to send unwanted
- * Location.changing events. For this reason, the identifier is reset to 0
- * when the top frame has either finished loading (didFinishLoadForFrame
- * event) or failed (didFailProvisionalLoadWithError).
- */
- identifier = 0;
- }
+ int /*long*/ cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+ OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types);
+ OS.class_addMethod(cls, OS.sel_webView_didChangeLocationWithinPageForFrame_, proc4, "@:@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_didFailProvisionalLoadWithError_forFrame_, proc5, "@:@@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_didFinishLoadForFrame_, proc4, "@:@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_didReceiveTitle_forFrame_, proc5, "@:@@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_didStartProvisionalLoadForFrame_, proc4, "@:@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_didCommitLoadForFrame_, proc4, "@:@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_resource_didFinishLoadingFromDataSource_, proc5, "@:@@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_resource_didFailLoadingWithError_fromDataSource_, proc6, "@:@@@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_identifierForInitialRequest_fromDataSource_, proc5, "@:@@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_resource_willSendRequest_redirectResponse_fromDataSource_, proc7, "@:@@@@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_handleNotification_, proc3, "@:@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_createWebViewWithRequest_, proc4, "@:@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webViewShow_, proc3, "@:@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webViewClose_, proc3, "@:@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_contextMenuItemsForElement_defaultMenuItems_, proc5, "@:@@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_setStatusBarVisible_, proc4, "@:@B"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_setResizable_, proc4, "@:@B"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_setToolbarsVisible_, proc4, "@:@B"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_setStatusText_, proc4, "@:@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webViewFocus_, proc3, "@:@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webViewUnfocus_, proc3, "@:@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_runJavaScriptAlertPanelWithMessage_, proc4, "@:@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_runJavaScriptConfirmPanelWithMessage_, proc4, "@:@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_runOpenPanelForFileButtonWithResultListener_, proc4, "@:@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_mouseDidMoveOverElement_modifierFlags_, proc5, "@:@@I"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_printFrameView_, proc4, "@:@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_decidePolicyForMIMEType_request_frame_decisionListener_, proc7, "@:@@@@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_decidePolicyForNavigationAction_request_frame_decisionListener_, proc7, "@:@@@@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener_, proc7, "@:@@@@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_unableToImplementPolicyWithError_frame_, proc5, "@:@@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_download_decideDestinationWithSuggestedFilename_, proc4, "@:@@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_handleEvent_, proc3, "@:@"); //$NON-NLS-1$
+ OS.class_addMethod(cls, OS.sel_webView_setFrame_, setFrameProc, "@:@{NSRect}"); //$NON-NLS-1$
+ OS.objc_registerClassPair(cls);
}
- void webView_didFinishLoadForFrame (int sender, int frameID)
- {
- hookDOMMouseListeners(frameID);
- if (frameID is webView.mainFrame().id)
- {
- hookDOMKeyListeners(frameID);
+ /*
+ * Override the default event mechanism to not send key events so
+ * that the browser can send them by listening to the DOM instead.
+ */
+ browser.setData(SAFARI_EVENTS_FIX_KEY);
+
+ WebView webView = (WebView)new WebView().alloc();
+ if (webView is null) DWT.error(DWT.ERROR_NO_HANDLES);
+ webView.initWithFrame(browser.view.frame(), null, null);
+ webView.setAutoresizingMask(OS.NSViewWidthSizable | OS.NSViewHeightSizable);
+ final SWTWebViewDelegate delegate = (SWTWebViewDelegate)new SWTWebViewDelegate().alloc().init();
+ Display display = browser.getDisplay();
+ display.setData(ADD_WIDGET_KEY, new Object[] {delegate, browser});
+ this.delegate = delegate;
+ this.webView = webView;
+ browser.view.addSubview(webView);
+
+ final NSNotificationCenter notificationCenter = NSNotificationCenter.defaultCenter();
- const Display display = browser.getDisplay();
- /*
- * To be consistent with other platforms a title event should be fired when a
- * page has completed loading. A page with a tag will do this
- * automatically when the didReceiveTitle callback is received. However a page
- * without a tag will not do this by default, so fire the event
- * here with the page's url as the title.
- */
- WebFrame frame = new WebFrame(frameID);
- WebDataSource dataSource = frame.dataSource();
- if (dataSource !is null)
- {
- NSString title = dataSource.pageTitle();
- if (title is null)
- { /* page has no title */
- const TitleEvent newEvent = new TitleEvent(browser);
- newEvent.display = display;
- newEvent.widget = browser;
- newEvent.title = url;
- for (int i = 0; i < titleListeners.length; i++)
- {
- const TitleListener listener = titleListeners[i];
- /*
- * Note on WebKit. Running the event loop from a Browser
- * delegatee callback breaks the WebKit (stop loading or
- * crash). The workaround is to invoke Display.asyncExec()
- * so that the Browser does not crash if this is attempted.
- */
- display.asyncExec(new class (display, listener) Runnable
- {
- Display display;
- TitleListener listener;
-
- this (Display display, TitleListener listener)
- {
- this.display = display;
- this.listener = listener;
- }
-
- public void run ()
- {
- if (!display.isDisposed() && !browser.isDisposed())
- {
- listener.changed(newEvent);
- }
- }
- });
+ Listener listener = new Listener() {
+ public void handleEvent(Event e) {
+ switch (e.type) {
+ case DWT.FocusIn:
+ Safari.this.webView.window().makeFirstResponder(Safari.this.webView);
+ break;
+ case DWT.Dispose: {
+ /* make this handler run after other dispose listeners */
+ if (ignoreDispose) {
+ ignoreDispose = false;
+ break;
}
+ ignoreDispose = true;
+ browser.notifyListeners (e.type, e);
+ e.type = DWT.NONE;
+
+ e.display.setData(ADD_WIDGET_KEY, new Object[] {delegate, null});
+
+ Safari.this.webView.setFrameLoadDelegate(null);
+ Safari.this.webView.setResourceLoadDelegate(null);
+ Safari.this.webView.setUIDelegate(null);
+ Safari.this.webView.setPolicyDelegate(null);
+ Safari.this.webView.setDownloadDelegate(null);
+ notificationCenter.removeObserver(delegate);
+
+ Safari.this.webView.release();
+ Safari.this.webView = null;
+ Safari.this.delegate.release();
+ Safari.this.delegate = null;
+ html = null;
+ lastHoveredLinkURL = null;
+ break;
}
}
- const ProgressEvent progress = new ProgressEvent(browser);
- progress.display = display;
- progress.widget = browser;
- progress.current = MAX_PROGRESS;
- progress.total = MAX_PROGRESS;
- for (int i = 0; i < progressListeners.length; i++)
- {
- const ProgressListener listener = progressListeners[i];
- /*
- * Note on WebKit. Running the event loop from a Browser
- * delegatee callback breaks the WebKit (stop loading or
- * crash). The ProgressBar widget currently touches the
- * event loop every time the method setSelection is called.
- * The workaround is to invoke Display.asyncExec() so that
- * the Browser does not crash when the user updates the
- * selection of the ProgressBar.
- */
- display.asyncExec(new class (display, listener) Runnable
- {
- Display display;
- ProgressListener listener;
-
- this (Display display, ProgressListener listener)
- {
- this.display = display;
- this.listener = listener;
- }
-
- public void run ()
- {
- if (!display.isDisposed() && !browser.isDisposed())
- {
- listener.completed(progress);
- }
- }
- });
- }
- /*
- * Feature on Safari. The identifier is used here as a marker for the events
- * related to the top frame and the URL changes related to that top frame as
- * they should appear on the location bar of a browser. It is expected to reset
- * the identifier to 0 when the event didFinishLoadingFromDataSource related to
- * the identifierForInitialRequest event is received. However, Safari fires
- * the didFinishLoadingFromDataSource event before the entire content of the
- * top frame is loaded. It is possible to receive multiple willSendRequest
- * events in this interval, causing the Browser widget to send unwanted
- * Location.changing events. For this reason, the identifier is reset to 0
- * when the top frame has either finished loading (didFinishLoadForFrame
- * event) or failed (didFailProvisionalLoadWithError).
- */
- identifier = 0;
}
- }
-
- void hookDOMKeyListeners (int frameID)
- {
- WebFrame frame = new WebFrame(frameID);
- DOMDocument document = frame.DOMDocument();
-
- NSString type = NSString.StringWith(DOMEVENT_KEYDOWN);
- document.addEventListener_listener_useCapture(type, delegatee, false);
+ };
+ browser.addListener(DWT.Dispose, listener);
+ /* Needed to be able to tab into the browser */
+ browser.addListener(DWT.KeyDown, listener);
+ browser.addListener(DWT.FocusIn, listener);
- type = NSString.StringWith(DOMEVENT_KEYUP);
- document.addEventListener_listener_useCapture(type, delegatee, false);
- }
+ webView.setFrameLoadDelegate(delegate);
+ webView.setResourceLoadDelegate(delegate);
+ webView.setUIDelegate(delegate);
+ notificationCenter.addObserver(delegate, OS.sel_handleNotification_, null, webView);
+ webView.setPolicyDelegate(delegate);
+ webView.setDownloadDelegate(delegate);
+ webView.setApplicationNameForUserAgent(NSString.stringWith(AGENT_STRING));
- void hookDOMMouseListeners (int frameID)
- {
- WebFrame frame = new WebFrame(frameID);
- DOMDocument document = frame.DOMDocument();
+ if (!Initialized) {
+ Initialized = true;
+ /* disable applets */
+ WebPreferences.standardPreferences().setJavaEnabled(false);
+ }
+}
- NSString type = NSString.StringWith(DOMEVENT_MOUSEDOWN);
- document.addEventListener_listener_useCapture(type, delegatee, false);
-
- type = NSString.StringWith(DOMEVENT_MOUSEUP);
- document.addEventListener_listener_useCapture(type, delegatee, false);
+public bool back() {
+ html = null;
+ return webView.goBack();
+}
- type = NSString.StringWith(DOMEVENT_MOUSEMOVE);
- document.addEventListener_listener_useCapture(type, delegatee, false);
-
- type = NSString.StringWith(DOMEVENT_MOUSEWHEEL);
- document.addEventListener_listener_useCapture(type, delegatee, false);
+static int /*long*/ browserProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) {
+ Widget widget = Display.getCurrent().findWidget(id);
+ if (widget is null) return 0;
+ Safari safari = (Safari)((Browser)widget).webBrowser;
+ if (sel is OS.sel_handleNotification_) {
+ safari.handleNotification(arg0);
+ } else if (sel is OS.sel_webViewShow_) {
+ safari.webViewShow(arg0);
+ } else if (sel is OS.sel_webViewClose_) {
+ safari.webViewClose(arg0);
+ } else if (sel is OS.sel_webViewFocus_) {
+ safari.webViewFocus(arg0);
+ } else if (sel is OS.sel_webViewUnfocus_) {
+ safari.webViewUnfocus(arg0);
+ } else if (sel is OS.sel_handleEvent_) {
+ safari.handleEvent(arg0);
}
+ return 0;
+}
- void webView_didReceiveTitle_forFrame (int sender, int titleID, int frameID)
- {
- if (frameID is webView.mainFrame().id)
- {
- NSString title = new NSString(titleID);
- char[] buffer = new char[title.length()];
- title.getCharacters_(buffer);
- String newTitle = new String(buffer);
- TitleEvent newEvent = new TitleEvent(browser);
- newEvent.display = browser.getDisplay();
- newEvent.widget = browser;
- newEvent.title = newTitle;
- for (int i = 0; i < titleListeners.length; i++)
- {
- titleListeners[i].changed(newEvent);
- }
- }
+static int /*long*/ browserProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int /*long*/ arg1) {
+ Widget widget = Display.getCurrent().findWidget(id);
+ if (widget is null) return 0;
+ Safari safari = (Safari)((Browser)widget).webBrowser;
+ if (sel is OS.sel_webView_didChangeLocationWithinPageForFrame_) {
+ safari.webView_didChangeLocationWithinPageForFrame(arg0, arg1);
+ } else if (sel is OS.sel_webView_didFinishLoadForFrame_) {
+ safari.webView_didFinishLoadForFrame(arg0, arg1);
+ } else if (sel is OS.sel_webView_didStartProvisionalLoadForFrame_) {
+ safari.webView_didStartProvisionalLoadForFrame(arg0, arg1);
+ } else if (sel is OS.sel_webView_didCommitLoadForFrame_) {
+ safari.webView_didCommitLoadForFrame(arg0, arg1);
+ } else if (sel is OS.sel_webView_setFrame_) {
+ safari.webView_setFrame(arg0, arg1);
+ } else if (sel is OS.sel_webView_createWebViewWithRequest_) {
+ return safari.webView_createWebViewWithRequest(arg0, arg1);
+ } else if (sel is OS.sel_webView_setStatusBarVisible_) {
+ safari.webView_setStatusBarVisible(arg0, arg1 !is 0);
+ } else if (sel is OS.sel_webView_setResizable_) {
+ safari.webView_setResizable(arg0, arg1 !is 0);
+ } else if (sel is OS.sel_webView_setStatusText_) {
+ safari.webView_setStatusText(arg0, arg1);
+ } else if (sel is OS.sel_webView_setToolbarsVisible_) {
+ safari.webView_setToolbarsVisible(arg0, arg1 !is 0);
+ } else if (sel is OS.sel_webView_runJavaScriptAlertPanelWithMessage_) {
+ safari.webView_runJavaScriptAlertPanelWithMessage(arg0, arg1);
+ } else if (sel is OS.sel_webView_runJavaScriptConfirmPanelWithMessage_) {
+ return safari.webView_runJavaScriptConfirmPanelWithMessage(arg0, arg1);
+ } else if (sel is OS.sel_webView_runOpenPanelForFileButtonWithResultListener_) {
+ safari.webView_runOpenPanelForFileButtonWithResultListener(arg0, arg1);
+ } else if (sel is OS.sel_download_decideDestinationWithSuggestedFilename_) {
+ safari.download_decideDestinationWithSuggestedFilename(arg0, arg1);
+ } else if (sel is OS.sel_webView_printFrameView_) {
+ safari.webView_printFrameView(arg0, arg1);
}
+ return 0;
+}
- void webView_didStartProvisionalLoadForFrame (int sender, int frameID)
- {
- /*
- * This code is intentionally commented. WebFrameLoadDelegate:didStartProvisionalLoadForFrame is
- * called before WebResourceLoadDelegate:willSendRequest and
- * WebFrameLoadDelegate:didCommitLoadForFrame. The resource count is reset when didCommitLoadForFrame
- * is received for the top frame.
- */
- // if (frameID is webView.mainFrame().id) {
- // /* reset resource status variables */
- // resourceCount= 0;
- // }
+static int /*long*/ browserProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2) {
+ Widget widget = Display.getCurrent().findWidget(id);
+ if (widget is null) return 0;
+ Safari safari = (Safari)((Browser)widget).webBrowser;
+ if (sel is OS.sel_webView_didFailProvisionalLoadWithError_forFrame_) {
+ safari.webView_didFailProvisionalLoadWithError_forFrame(arg0, arg1, arg2);
+ } else if (sel is OS.sel_webView_didReceiveTitle_forFrame_) {
+ safari.webView_didReceiveTitle_forFrame(arg0, arg1, arg2);
+ } else if (sel is OS.sel_webView_resource_didFinishLoadingFromDataSource_) {
+ safari.webView_resource_didFinishLoadingFromDataSource(arg0, arg1, arg2);
+ } else if (sel is OS.sel_webView_identifierForInitialRequest_fromDataSource_) {
+ return safari.webView_identifierForInitialRequest_fromDataSource(arg0, arg1, arg2);
+ } else if (sel is OS.sel_webView_contextMenuItemsForElement_defaultMenuItems_) {
+ return safari.webView_contextMenuItemsForElement_defaultMenuItems(arg0, arg1, arg2);
+ } else if (sel is OS.sel_webView_mouseDidMoveOverElement_modifierFlags_) {
+ safari.webView_mouseDidMoveOverElement_modifierFlags(arg0, arg1, arg2);
+ } else if (sel is OS.sel_webView_unableToImplementPolicyWithError_frame_) {
+ safari.webView_unableToImplementPolicyWithError_frame(arg0, arg1, arg2);
}
+ return 0;
+}
- void webView_didCommitLoadForFrame (int sender, int frameID)
- {
- WebFrame frame = new WebFrame(frameID);
- WebDataSource dataSource = frame.dataSource();
- NSURLRequest request = dataSource.request();
- NSURL url = request.URL();
- NSString s = url.absoluteString();
- int length = s.length();
- if (length is 0)
- return;
- char[] buffer = new char[length];
- s.getCharacters_(buffer);
- String url2 = new String(buffer);
- /*
- * If the URI indicates that the page is being rendered from memory
- * (via setText()) then set it to about:blank to be consistent with IE.
- */
- if (url2.opEquals(URI_FROMMEMORY))
- url2 = ABOUT_BLANK;
+static int /*long*/ browserProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3) {
+ Widget widget = Display.getCurrent().findWidget(id);
+ if (widget is null) return 0;
+ Safari safari = (Safari)((Browser)widget).webBrowser;
+ if (sel is OS.sel_webView_resource_didFailLoadingWithError_fromDataSource_) {
+ safari.webView_resource_didFailLoadingWithError_fromDataSource(arg0, arg1, arg2, arg3);
+ }
+ return 0;
+}
- const Display display = browser.getDisplay();
- bool top = frameID is webView.mainFrame().id;
- if (top)
- {
- /* reset resource status variables */
- resourceCount = 0;
- this.url = url2;
+static int /*long*/ browserProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ arg4) {
+ Widget widget = Display.getCurrent().findWidget(id);
+ if (widget is null) return 0;
+ Safari safari = (Safari)((Browser)widget).webBrowser;
+ if (sel is OS.sel_webView_resource_willSendRequest_redirectResponse_fromDataSource_) {
+ return safari.webView_resource_willSendRequest_redirectResponse_fromDataSource(arg0, arg1, arg2, arg3, arg4);
+ } else if (sel is OS.sel_webView_decidePolicyForMIMEType_request_frame_decisionListener_) {
+ safari.webView_decidePolicyForMIMEType_request_frame_decisionListener(arg0, arg1, arg2, arg3, arg4);
+ } else if (sel is OS.sel_webView_decidePolicyForNavigationAction_request_frame_decisionListener_) {
+ safari.webView_decidePolicyForNavigationAction_request_frame_decisionListener(arg0, arg1, arg2, arg3, arg4);
+ } else if (sel is OS.sel_webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener_) {
+ safari.webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener(arg0, arg1, arg2, arg3, arg4);
+ }
+ return 0;
+}
+
+public bool execute(String script) {
+ return webView.stringByEvaluatingJavaScriptFromString(NSString.stringWith(script)) !is null;
+}
+
+public bool forward() {
+ html = null;
+ return webView.goForward();
+}
- const ProgressEvent progress = new ProgressEvent(browser);
- progress.display = display;
- progress.widget = browser;
- progress.current = 1;
- progress.total = MAX_PROGRESS;
- for (int i = 0; i < progressListeners.length; i++)
- {
- const ProgressListener listener = progressListeners[i];
- /*
- * Note on WebKit. Running the event loop from a Browser
- * delegatee callback breaks the WebKit (stop loading or
- * crash). The widget ProgressBar currently touches the
- * event loop every time the method setSelection is called.
- * The workaround is to invoke Display.asyncexec so that
- * the Browser does not crash when the user updates the
- * selection of the ProgressBar.
- */
- display.asyncExec(new class (display, listener) Runnable
- {
- Display display;
- ProgressListener listener;
-
- this (Display display, ProgressListener listener)
- {
- this.display = display;
- this.listener = listener;
- }
-
- public void run ()
- {
- if (!display.isDisposed() && !browser.isDisposed())
- listener.changed(progress);
- }
- });
- }
+public String getBrowserType () {
+ return "safari"; //$NON-NLS-1$
+}
+
+public String getText() {
+ WebFrame mainFrame = webView.mainFrame();
+ WebDataSource dataSource = mainFrame.dataSource();
+ if (dataSource is null) return ""; //$NON-NLS-1$
+ WebDocumentRepresentation representation = dataSource.representation();
+ if (representation is null) return ""; //$NON-NLS-1$
+ NSString source = representation.documentSource();
+ if (source is null) return ""; //$NON-NLS-1$
+ return source.getString();
+}
+
+public String getUrl() {
+ return url;
+}
+
+public bool isBackEnabled() {
+ return webView.canGoBack();
+}
+
+public bool isForwardEnabled() {
+ return webView.canGoForward();
+}
- StatusTextEvent statusText = new StatusTextEvent(browser);
- statusText.display = display;
- statusText.widget = browser;
- statusText.text = url2;
- for (int i = 0; i < statusTextListeners.length; i++)
- {
- statusTextListeners[i].changed(statusText);
- }
- }
- LocationEvent location = new LocationEvent(browser);
- location.display = display;
- location.widget = browser;
- location.location = url2;
- location.top = top;
- for (int i = 0; i < locationListeners.length; i++)
- {
- locationListeners[i].changed(location);
- }
- }
+public void refresh() {
+ webView.reload(null);
+}
- /* WebResourceLoadDelegate */
-
- void webView_resource_didFinishLoadingFromDataSource (int sender, int identifier, int dataSource)
- {
+public bool setText(String html) {
/*
- * Feature on Safari. The identifier is used here as a marker for the events
- * related to the top frame and the URL changes related to that top frame as
- * they should appear on the location bar of a browser. It is expected to reset
- * the identifier to 0 when the event didFinishLoadingFromDataSource related to
- * the identifierForInitialRequest event is received. However, Safari fires
- * the didFinishLoadingFromDataSource event before the entire content of the
- * top frame is loaded. It is possible to receive multiple willSendRequest
- * events in this interval, causing the Browser widget to send unwanted
- * Location.changing events. For this reason, the identifier is reset to 0
- * when the top frame has either finished loading (didFinishLoadForFrame
- * event) or failed (didFailProvisionalLoadWithError).
- */
- // this code is intentionally commented
- //if (this.identifier is identifier) this.identifier = 0;
+ * Bug in Safari. The web view segment faults in some circumstances
+ * when the text changes during the location changing callback. The
+ * fix is to defer the work until the callback is done.
+ */
+ if (changingLocation) {
+ this.html = html;
+ } else {
+ _setText(html);
+ }
+ return true;
+}
+
+void _setText(String html) {
+ NSString string = NSString.stringWith(html);
+ NSString URLString = NSString.stringWith(URI_FROMMEMORY);
+ NSURL URL = NSURL.URLWithString(URLString);
+ WebFrame mainFrame = webView.mainFrame();
+ mainFrame.loadHTMLString(string, URL);
+}
+
+public bool setUrl(String url) {
+ html = null;
+
+ if (url.indexOf('/') is 0) {
+ url = PROTOCOL_FILE + url;
+ } else if (url.indexOf(':') is -1) {
+ url = PROTOCOL_HTTP + url;
}
- void webView_resource_didFailLoadingWithError_fromDataSource (int sender, int identifier, int error, int dataSource)
- {
- /*
- * Feature on Safari. The identifier is used here as a marker for the events
- * related to the top frame and the URL changes related to that top frame as
- * they should appear on the location bar of a browser. It is expected to reset
- * the identifier to 0 when the event didFinishLoadingFromDataSource related to
- * the identifierForInitialRequest event is received. However, Safari fires
- * the didFinishLoadingFromDataSource event before the entire content of the
- * top frame is loaded. It is possible to receive multiple willSendRequest
- * events in this interval, causing the Browser widget to send unwanted
- * Location.changing events. For this reason, the identifier is reset to 0
- * when the top frame has either finished loading (didFinishLoadForFrame
- * event) or failed (didFailProvisionalLoadWithError).
- */
- // this code is intentionally commented
- //if (this.identifier is identifier) this.identifier = 0;
- }
+ NSString str = NSString.stringWith(url);
+ NSString unescapedStr = NSString.stringWith("%#"); //$NON-NLS-1$
+ int /*long*/ ptr = OS.CFURLCreateStringByAddingPercentEscapes(0, str.id, unescapedStr.id, 0, OS.kCFStringEncodingUTF8);
+ NSString escapedString = new NSString(ptr);
+ NSURL inURL = NSURL.URLWithString(escapedString);
+ OS.CFRelease(ptr);
+ NSURLRequest request = NSURLRequest.requestWithURL(inURL);
+ WebFrame mainFrame = webView.mainFrame();
+ mainFrame.loadRequest(request);
+ return true;
+}
- int webView_identifierForInitialRequest_fromDataSource (int sender, int request, int dataSourceID)
- {
- const Display display = browser.getDisplay();
- const ProgressEvent progress = new ProgressEvent(browser);
- progress.display = display;
- progress.widget = browser;
- progress.current = resourceCount;
- progress.total = Math.max(resourceCount, MAX_PROGRESS);
- for (int i = 0; i < progressListeners.length; i++)
- {
- const ProgressListener listener = progressListeners[i];
- /*
- * Note on WebKit. Running the event loop from a Browser
- * delegatee callback breaks the WebKit (stop loading or
- * crash). The widget ProgressBar currently touches the
- * event loop every time the method setSelection is called.
- * The workaround is to invoke Display.asyncexec so that
- * the Browser does not crash when the user updates the
- * selection of the ProgressBar.
- */
- display.asyncExec(new class (display, listener) Runnable
- {
- Display display;
- ProgressListener listener;
-
- this (Display display, ProgressListener listener)
- {
- this.display = display;
- this.listener = listener;
- }
-
- public void run ()
- {
- if (!display.isDisposed() && !browser.isDisposed())
- listener.changed(progress);
- }
- });
- }
+public void stop() {
+ html = null;
+ webView.stopLoading(null);
+}
- NSNumber identifier = NSNumber.numberWithInt(resourceCount++);
- if (this.identifier is 0)
- {
- WebDataSource dataSource = new WebDataSource(dataSourceID);
- WebFrame frame = dataSource.webFrame();
- if (frame.id is webView.mainFrame().id)
- this.identifier = identifier.id;
- }
- return identifier.id;
-
- }
-
- int webView_resource_willSendRequest_redirectResponse_fromDataSource (int sender, int identifier, int request, int redirectResponse,
- int dataSource)
- {
- return request;
- }
-
- /* handleNotification */
-
- void handleNotification (int notification)
- {
- }
-
- /* UIDelegate */
- int webView_createWebViewWithRequest (int sender, int request)
- {
- WindowEvent newEvent = new WindowEvent(browser);
- newEvent.display = browser.getDisplay();
- newEvent.widget = browser;
- newEvent.required = true;
- if (openWindowListeners !is null)
- {
- for (int i = 0; i < openWindowListeners.length; i++)
- {
- openWindowListeners[i].open(newEvent);
- }
- }
- Browser browser = null;
- if (newEvent.browser !is null && cast(Safari) newEvent.browser.webBrowser)
- {
- browser = newEvent.browser;
- }
- if (browser !is null && !browser.isDisposed())
- {
- if (request !is 0)
- {
- WebFrame mainFrame = webView.mainFrame();
- mainFrame.loadRequest(new NSURLRequest(request));
- }
- }
- return webView.id;
- }
+/* WebFrameLoadDelegate */
- void webViewShow (int sender)
- {
- /*
- * Feature on WebKit. The Safari WebKit expects the application
- * to create a new Window using the Objective C Cocoa API in response
- * to UIDelegate.createWebViewWithRequest. The application is then
- * expected to use Objective C Cocoa API to make this window visible
- * when receiving the UIDelegate.webViewShow message. For some reason,
- * a window created with the Carbon API hosting the new browser instance
- * does not redraw until it has been resized. The fix is to increase the
- * size of the Shell and restore it to its initial size.
- */
- Shell parent = browser.getShell();
- Point pt = parent.getSize();
- parent.setSize(pt.x + 1, pt.y);
- parent.setSize(pt.x, pt.y);
- WindowEvent newEvent = new WindowEvent(browser);
- newEvent.display = browser.getDisplay();
- newEvent.widget = browser;
- if (location !is null)
- newEvent.location = location;
- if (size !is null)
- newEvent.size = size;
- /*
- * Feature in Safari. Safari's tool bar contains
- * the address bar. The address bar is displayed
- * if the tool bar is displayed. There is no separate
- * notification for the address bar.
- * Feature in Safari. The menu bar is always
- * displayed. There is no notification to hide
- * the menu bar.
- */
- newEvent.addressBar = toolBar;
- newEvent.menuBar = true;
- newEvent.statusBar = statusBar;
- newEvent.toolBar = toolBar;
- for (int i = 0; i < visibilityWindowListeners.length; i++)
- {
- visibilityWindowListeners[i].show(newEvent);
- }
- location = null;
- size = null;
- }
-
- void webView_setFrame (int sender, int frame)
- {
- float[] dest = new float[4];
- OS.memmove(dest, frame, 16);
- /* convert to DWT system coordinates */
- Rectangle bounds = browser.getDisplay().getBounds();
- location = new Point(cast(int) dest[0], bounds.height - cast(int) dest[1] - cast(int) dest[3]);
- size = new Point(cast(int) dest[2], cast(int) dest[3]);
- }
-
- void webViewFocus (int sender)
- {
- }
-
- void webViewUnfocus (int sender)
- {
- }
-
- void webView_runJavaScriptAlertPanelWithMessage (int sender, int messageID)
- {
- NSString message = new NSString(messageID);
- char[] buffer = new char[message.length()];
- message.getCharacters_(buffer);
- String text = new String(buffer);
-
- MessageBox messageBox = new MessageBox(browser.getShell(), DWT.OK | DWT.ICON_WARNING);
- messageBox.setText("Javascript"); //$NON-NLS-1$
- messageBox.setMessage(text);
- messageBox.open();
- }
-
- int webView_runJavaScriptConfirmPanelWithMessage (int sender, int messageID)
- {
- NSString message = new NSString(messageID);
- char[] buffer = new char[message.length()];
- message.getCharacters_(buffer);
- String text = new String(buffer);
+void webView_didChangeLocationWithinPageForFrame(int /*long*/ sender, int /*long*/ frameID) {
+ WebFrame frame = new WebFrame(frameID);
+ WebDataSource dataSource = frame.dataSource();
+ NSURLRequest request = dataSource.request();
+ NSURL url = request.URL();
+ NSString s = url.absoluteString();
+ int length = (int)/*64*/s.length();
+ if (length is 0) return;
+ String url2 = s.getString();
+ /*
+ * If the URI indicates that the page is being rendered from memory
+ * (via setText()) then set it to about:blank to be consistent with IE.
+ */
+ if (url2.equals (URI_FROMMEMORY)) url2 = ABOUT_BLANK;
- MessageBox messageBox = new MessageBox(browser.getShell(), DWT.OK | DWT.CANCEL | DWT.ICON_QUESTION);
- messageBox.setText("Javascript"); //$NON-NLS-1$
- messageBox.setMessage(text);
- return messageBox.open() is DWT.OK ? 1 : 0;
- }
-
- void webView_runOpenPanelForFileButtonWithResultListener (int sender, int resultListenerID)
- {
- FileDialog dialog = new FileDialog(browser.getShell(), DWT.NONE);
- String result = dialog.open();
- WebOpenPanelResultListener resultListener = new WebOpenPanelResultListener(resultListenerID);
- if (result is null)
- {
- resultListener.cancel();
- return;
- }
- resultListener.chooseFilename(NSString.StringWith(result));
- }
-
- void webViewClose (int sender)
- {
- Shell parent = browser.getShell();
- WindowEvent newEvent = new WindowEvent(browser);
- newEvent.display = browser.getDisplay();
- newEvent.widget = browser;
- for (int i = 0; i < closeWindowListeners.length; i++)
- {
- closeWindowListeners[i].close(newEvent);
- }
- browser.dispose();
- if (parent.isDisposed())
- return;
- /*
- * Feature on WebKit. The Safari WebKit expects the application
- * to create a new Window using the Objective C Cocoa API in response
- * to UIDelegate.createWebViewWithRequest. The application is then
- * expected to use Objective C Cocoa API to make this window visible
- * when receiving the UIDelegate.webViewShow message. For some reason,
- * a window created with the Carbon API hosting the new browser instance
- * does not redraw until it has been resized. The fix is to increase the
- * size of the Shell and restore it to its initial size.
- */
- Point pt = parent.getSize();
- parent.setSize(pt.x + 1, pt.y);
- parent.setSize(pt.x, pt.y);
- }
-
- int webView_contextMenuItemsForElement_defaultMenuItems (int sender, int element, int defaultMenuItems)
- {
- Point pt = browser.getDisplay().getCursorLocation();
- Event event = new Event();
- event.x = pt.x;
- event.y = pt.y;
- browser.notifyListeners(DWT.MenuDetect, event);
- Menu menu = browser.getMenu();
- if (!event.doit)
- return 0;
- if (menu !is null && !menu.isDisposed())
- {
- if (event.x !is pt.x || event.y !is pt.y)
- {
- menu.setLocation(event.x, event.y);
- }
- menu.setVisible(true);
- return 0;
- }
- return defaultMenuItems;
- }
-
- void webView_setStatusBarVisible (int sender, int visible)
- {
- /* Note. Webkit only emits the notification when the status bar should be hidden. */
- statusBar = visible !is 0;
- }
-
- void webView_setStatusText (int sender, int textID)
- {
- NSString text = new NSString(textID);
- int length = text.length();
- if (length is 0)
- return;
- char[] buffer = new char[length];
- text.getCharacters_(buffer);
-
+ final Display display = browser.getDisplay();
+ bool top = frameID is webView.mainFrame().id;
+ if (top) {
StatusTextEvent statusText = new StatusTextEvent(browser);
- statusText.display = browser.getDisplay();
+ statusText.display = display;
statusText.widget = browser;
- statusText.text = new String(buffer);
- for (int i = 0; i < statusTextListeners.length; i++)
- {
+ statusText.text = url2;
+ for (int i = 0; i < statusTextListeners.length; i++) {
statusTextListeners[i].changed(statusText);
}
}
- void webView_setResizable (int sender, int visible)
- {
+ LocationEvent location = new LocationEvent(browser);
+ location.display = display;
+ location.widget = browser;
+ location.location = url2;
+ location.top = top;
+ for (int i = 0; i < locationListeners.length; i++) {
+ locationListeners[i].changed(location);
}
+}
- void webView_setToolbarsVisible (int sender, int visible)
- {
- /* Note. Webkit only emits the notification when the tool bar should be hidden. */
- toolBar = visible !is 0;
+void webView_didFailProvisionalLoadWithError_forFrame(int /*long*/ sender, int /*long*/ error, int /*long*/ frame) {
+ if (frame is webView.mainFrame().id) {
+ /*
+ * Feature on Safari. The identifier is used here as a marker for the events
+ * related to the top frame and the URL changes related to that top frame as
+ * they should appear on the location bar of a browser. It is expected to reset
+ * the identifier to 0 when the event didFinishLoadingFromDataSource related to
+ * the identifierForInitialRequest event is received. However, Safari fires
+ * the didFinishLoadingFromDataSource event before the entire content of the
+ * top frame is loaded. It is possible to receive multiple willSendRequest
+ * events in this interval, causing the Browser widget to send unwanted
+ * Location.changing events. For this reason, the identifier is reset to 0
+ * when the top frame has either finished loading (didFinishLoadForFrame
+ * event) or failed (didFailProvisionalLoadWithError).
+ */
+ identifier = 0;
}
- void webView_mouseDidMoveOverElement_modifierFlags (int sender, int elementInformationID, int modifierFlags)
- {
- if (elementInformationID is 0)
- return;
+ NSError nserror = new NSError(error);
+ int /*long*/ errorCode = nserror.code();
+ if (errorCode <= OS.NSURLErrorBadURL) {
+ NSString description = nserror.localizedDescription();
+ if (description !is null) {
+ String descriptionString = description.getString();
+ String urlString = null;
+ NSDictionary info = nserror.userInfo();
+ if (info !is null) {
+ NSString key = new NSString(OS.NSErrorFailingURLStringKey());
+ id id = info.valueForKey(key);
+ if (id !is null) {
+ NSString url = new NSString(id);
+ urlString = url.getString();
+ }
+ }
+ String message = urlString !is null ? urlString + "\n\n" : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ message += Compatibility.getMessage ("DWT_Page_Load_Failed", new Object[] {descriptionString}); //$NON-NLS-1$
+ MessageBox messageBox = new MessageBox(browser.getShell(), DWT.OK | DWT.ICON_ERROR);
+ messageBox.setMessage(message);
+ messageBox.open();
+ }
+ }
+}
+
+void webView_didFinishLoadForFrame(int /*long*/ sender, int /*long*/ frameID) {
+ hookDOMMouseListeners(frameID);
+ if (frameID is webView.mainFrame().id) {
+ hookDOMKeyListeners(frameID);
- NSString key = NSString.StringWith(WebElementLinkURLKey);
- NSDictionary elementInformation = new NSDictionary(elementInformationID);
- id value = elementInformation.valueForKey(key);
- if (value is null)
- {
- /* not currently over a link */
- if (lastHoveredLinkURL is null)
- return;
- lastHoveredLinkURL = null;
- StatusTextEvent statusText = new StatusTextEvent(browser);
- statusText.display = browser.getDisplay();
- statusText.widget = browser;
- statusText.text = ""; //$NON-NLS-1$
- for (int i = 0; i < statusTextListeners.length; i++)
- {
- statusTextListeners[i].changed(statusText);
+ final Display display = browser.getDisplay();
+ /*
+ * To be consistent with other platforms a title event should be fired when a
+ * page has completed loading. A page with a tag will do this
+ * automatically when the didReceiveTitle callback is received. However a page
+ * without a tag will not do this by default, so fire the event
+ * here with the page's url as the title.
+ */
+ WebFrame frame = new WebFrame(frameID);
+ WebDataSource dataSource = frame.dataSource();
+ if (dataSource !is null) {
+ NSString title = dataSource.pageTitle();
+ if (title is null) { /* page has no title */
+ final TitleEvent newEvent = new TitleEvent(browser);
+ newEvent.display = display;
+ newEvent.widget = browser;
+ newEvent.title = url;
+ for (int i = 0; i < titleListeners.length; i++) {
+ final TitleListener listener = titleListeners[i];
+ /*
+ * Note on WebKit. Running the event loop from a Browser
+ * delegate callback breaks the WebKit (stop loading or
+ * crash). The workaround is to invoke Display.asyncExec()
+ * so that the Browser does not crash if this is attempted.
+ */
+ display.asyncExec(
+ new Runnable() {
+ public void run() {
+ if (!display.isDisposed() && !browser.isDisposed()) {
+ listener.changed(newEvent);
+ }
+ }
+ }
+ );
+ }
}
- return;
+ }
+ final ProgressEvent progress = new ProgressEvent(browser);
+ progress.display = display;
+ progress.widget = browser;
+ progress.current = MAX_PROGRESS;
+ progress.total = MAX_PROGRESS;
+ for (int i = 0; i < progressListeners.length; i++) {
+ final ProgressListener listener = progressListeners[i];
+ /*
+ * Note on WebKit. Running the event loop from a Browser
+ * delegate callback breaks the WebKit (stop loading or
+ * crash). The ProgressBar widget currently touches the
+ * event loop every time the method setSelection is called.
+ * The workaround is to invoke Display.asyncExec() so that
+ * the Browser does not crash when the user updates the
+ * selection of the ProgressBar.
+ */
+ display.asyncExec(
+ new Runnable() {
+ public void run() {
+ if (!display.isDisposed() && !browser.isDisposed()) {
+ listener.completed(progress);
+ }
+ }
+ }
+ );
+ }
+ /*
+ * Feature on Safari. The identifier is used here as a marker for the events
+ * related to the top frame and the URL changes related to that top frame as
+ * they should appear on the location bar of a browser. It is expected to reset
+ * the identifier to 0 when the event didFinishLoadingFromDataSource related to
+ * the identifierForInitialRequest event is received. However, Safari fires
+ * the didFinishLoadingFromDataSource event before the entire content of the
+ * top frame is loaded. It is possible to receive multiple willSendRequest
+ * events in this interval, causing the Browser widget to send unwanted
+ * Location.changing events. For this reason, the identifier is reset to 0
+ * when the top frame has either finished loading (didFinishLoadForFrame
+ * event) or failed (didFailProvisionalLoadWithError).
+ */
+ identifier = 0;
+ }
+}
+
+void hookDOMKeyListeners(int /*long*/ frameID) {
+ WebFrame frame = new WebFrame(frameID);
+ DOMDocument document = frame.DOMDocument();
+
+ NSString type = NSString.stringWith(DOMEVENT_KEYDOWN);
+ document.addEventListener(type, delegate, false);
+
+ type = NSString.stringWith(DOMEVENT_KEYUP);
+ document.addEventListener(type, delegate, false);
+}
+
+void hookDOMMouseListeners(int /*long*/ frameID) {
+ WebFrame frame = new WebFrame(frameID);
+ DOMDocument document = frame.DOMDocument();
+
+ NSString type = NSString.stringWith(DOMEVENT_MOUSEDOWN);
+ document.addEventListener(type, delegate, false);
+
+ type = NSString.stringWith(DOMEVENT_MOUSEUP);
+ document.addEventListener(type, delegate, false);
+
+ type = NSString.stringWith(DOMEVENT_MOUSEMOVE);
+ document.addEventListener(type, delegate, false);
+
+ type = NSString.stringWith(DOMEVENT_MOUSEWHEEL);
+ document.addEventListener(type, delegate, false);
+}
+
+void webView_didReceiveTitle_forFrame(int /*long*/ sender, int /*long*/ titleID, int /*long*/ frameID) {
+ if (frameID is webView.mainFrame().id) {
+ NSString title = new NSString(titleID);
+ String newTitle = title.getString();
+ TitleEvent newEvent = new TitleEvent(browser);
+ newEvent.display = browser.getDisplay();
+ newEvent.widget = browser;
+ newEvent.title = newTitle;
+ for (int i = 0; i < titleListeners.length; i++) {
+ titleListeners[i].changed(newEvent);
+ }
+ }
+}
+
+void webView_didStartProvisionalLoadForFrame(int /*long*/ sender, int /*long*/ frameID) {
+ /*
+ * This code is intentionally commented. WebFrameLoadDelegate:didStartProvisionalLoadForFrame is
+ * called before WebResourceLoadDelegate:willSendRequest and
+ * WebFrameLoadDelegate:didCommitLoadForFrame. The resource count is reset when didCommitLoadForFrame
+ * is received for the top frame.
+ */
+// if (frameID is webView.mainFrame().id) {
+// /* reset resource status variables */
+// resourceCount= 0;
+// }
+}
+
+void webView_didCommitLoadForFrame(int /*long*/ sender, int /*long*/ frameID) {
+ WebFrame frame = new WebFrame(frameID);
+ WebDataSource dataSource = frame.dataSource();
+ NSURLRequest request = dataSource.request();
+ NSURL url = request.URL();
+ NSString s = url.absoluteString();
+ int length = (int)/*64*/s.length();
+ if (length is 0) return;
+ String url2 = s.getString();
+ /*
+ * If the URI indicates that the page is being rendered from memory
+ * (via setText()) then set it to about:blank to be consistent with IE.
+ */
+ if (url2.equals (URI_FROMMEMORY)) url2 = ABOUT_BLANK;
+
+ final Display display = browser.getDisplay();
+ bool top = frameID is webView.mainFrame().id;
+ if (top) {
+ /* reset resource status variables */
+ resourceCount = 0;
+ this.url = url2;
+
+ final ProgressEvent progress = new ProgressEvent(browser);
+ progress.display = display;
+ progress.widget = browser;
+ progress.current = 1;
+ progress.total = MAX_PROGRESS;
+ for (int i = 0; i < progressListeners.length; i++) {
+ final ProgressListener listener = progressListeners[i];
+ /*
+ * Note on WebKit. Running the event loop from a Browser
+ * delegate callback breaks the WebKit (stop loading or
+ * crash). The widget ProgressBar currently touches the
+ * event loop every time the method setSelection is called.
+ * The workaround is to invoke Display.asyncexec so that
+ * the Browser does not crash when the user updates the
+ * selection of the ProgressBar.
+ */
+ display.asyncExec(
+ new Runnable() {
+ public void run() {
+ if (!display.isDisposed() && !browser.isDisposed())
+ listener.changed(progress);
+ }
+ }
+ );
}
- NSString url = (new NSURL(value.id)).absoluteString();
- int length = url.length();
- String urlString;
- if (length is 0)
- {
- urlString = ""; //$NON-NLS-1$
- }
- else
- {
- char[] buffer = new char[length];
- url.getCharacters_(buffer);
- urlString = new String(buffer);
- }
- if (urlString.opEquals(lastHoveredLinkURL))
- return;
-
- lastHoveredLinkURL = urlString;
StatusTextEvent statusText = new StatusTextEvent(browser);
- statusText.display = browser.getDisplay();
+ statusText.display = display;
statusText.widget = browser;
- statusText.text = urlString;
- for (int i = 0; i < statusTextListeners.length; i++)
- {
+ statusText.text = url2;
+ for (int i = 0; i < statusTextListeners.length; i++) {
statusTextListeners[i].changed(statusText);
}
}
+ LocationEvent location = new LocationEvent(browser);
+ location.display = display;
+ location.widget = browser;
+ location.location = url2;
+ location.top = top;
+ for (int i = 0; i < locationListeners.length; i++) {
+ locationListeners[i].changed(location);
+ }
+}
- void webView_printFrameView (int sender, int frameViewID)
- {
- WebFrameView view = new WebFrameView(frameViewID);
- bool viewPrint = view.documentViewShouldHandlePrint();
- if (viewPrint)
- {
- view.printDocumentView();
- return;
- }
- NSPrintInfo info = NSPrintInfo.sharedPrintInfo();
- NSPrintOperation operation = view.printOperationWithPrintInfo(info);
- if (operation !is null)
- operation.runOperation();
- }
+/* WebResourceLoadDelegate */
- /* PolicyDelegate */
-
- void webView_decidePolicyForMIMEType_request_frame_decisionListener (int sender, int type, int request, int frame, int listenerID)
- {
- bool canShow = WebView.canShowMIMEType(new NSString(type));
- WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID);
- if (canShow)
- {
- listener.use();
- }
- else
- {
- listener.download();
- }
- }
+void webView_resource_didFinishLoadingFromDataSource(int /*long*/ sender, int /*long*/ identifier, int /*long*/ dataSource) {
+ /*
+ * Feature on Safari. The identifier is used here as a marker for the events
+ * related to the top frame and the URL changes related to that top frame as
+ * they should appear on the location bar of a browser. It is expected to reset
+ * the identifier to 0 when the event didFinishLoadingFromDataSource related to
+ * the identifierForInitialRequest event is received. However, Safari fires
+ * the didFinishLoadingFromDataSource event before the entire content of the
+ * top frame is loaded. It is possible to receive multiple willSendRequest
+ * events in this interval, causing the Browser widget to send unwanted
+ * Location.changing events. For this reason, the identifier is reset to 0
+ * when the top frame has either finished loading (didFinishLoadForFrame
+ * event) or failed (didFailProvisionalLoadWithError).
+ */
+ // this code is intentionally commented
+ //if (this.identifier is identifier) this.identifier = 0;
+}
- void webView_decidePolicyForNavigationAction_request_frame_decisionListener (int sender, int actionInformation, int request, int frame,
- int listenerID)
- {
- NSURL url = (new NSURLRequest(request)).URL();
- WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID);
- if (url is null)
- {
- /* indicates that a URL with an invalid format was specified */
- listener.ignore();
- return;
- }
- NSString s = url.absoluteString();
- char[] buffer = new char[s.length()];
- s.getCharacters_(buffer);
- String url2 = new String(buffer);
- /*
- * If the URI indicates that the page is being rendered from memory
- * (via setText()) then set it to about:blank to be consistent with IE.
- */
- if (url2.opEquals(URI_FROMMEMORY))
- url2 = ABOUT_BLANK;
+void webView_resource_didFailLoadingWithError_fromDataSource(int /*long*/ sender, int /*long*/ identifier, int /*long*/ error, int /*long*/ dataSource) {
+ /*
+ * Feature on Safari. The identifier is used here as a marker for the events
+ * related to the top frame and the URL changes related to that top frame as
+ * they should appear on the location bar of a browser. It is expected to reset
+ * the identifier to 0 when the event didFinishLoadingFromDataSource related to
+ * the identifierForInitialRequest event is received. However, Safari fires
+ * the didFinishLoadingFromDataSource event before the entire content of the
+ * top frame is loaded. It is possible to receive multiple willSendRequest
+ * events in this interval, causing the Browser widget to send unwanted
+ * Location.changing events. For this reason, the identifier is reset to 0
+ * when the top frame has either finished loading (didFinishLoadForFrame
+ * event) or failed (didFailProvisionalLoadWithError).
+ */
+ // this code is intentionally commented
+ //if (this.identifier is identifier) this.identifier = 0;
+}
- LocationEvent newEvent = new LocationEvent(browser);
- newEvent.display = browser.getDisplay();
- newEvent.widget = browser;
- newEvent.location = url2;
- newEvent.doit = true;
- if (locationListeners !is null)
- {
- changingLocation = true;
- for (int i = 0; i < locationListeners.length; i++)
- {
- locationListeners[i].changing(newEvent);
+int /*long*/ webView_identifierForInitialRequest_fromDataSource(int /*long*/ sender, int /*long*/ request, int /*long*/ dataSourceID) {
+ final Display display = browser.getDisplay();
+ final ProgressEvent progress = new ProgressEvent(browser);
+ progress.display = display;
+ progress.widget = browser;
+ progress.current = resourceCount;
+ progress.total = Math.max(resourceCount, MAX_PROGRESS);
+ for (int i = 0; i < progressListeners.length; i++) {
+ final ProgressListener listener = progressListeners[i];
+ /*
+ * Note on WebKit. Running the event loop from a Browser
+ * delegate callback breaks the WebKit (stop loading or
+ * crash). The widget ProgressBar currently touches the
+ * event loop every time the method setSelection is called.
+ * The workaround is to invoke Display.asyncexec so that
+ * the Browser does not crash when the user updates the
+ * selection of the ProgressBar.
+ */
+ display.asyncExec(
+ new Runnable() {
+ public void run() {
+ if (!display.isDisposed() && !browser.isDisposed())
+ listener.changed(progress);
+ }
}
- changingLocation = false;
- }
- if (newEvent.doit)
- {
- listener.use();
- }
- else
- {
- listener.ignore();
- }
- if (html !is null && !browser.isDisposed())
- {
- String html = this.html;
- this.html = null;
- _setText(html);
- }
- }
-
- void webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener (int sender, int actionInformation, int request, int frameName,
- int listenerID)
- {
- WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID);
- listener.use();
+ );
}
- void webView_unableToImplementPolicyWithError_frame (int sender, int error, int frame)
- {
+ NSNumber identifier = NSNumber.numberWithInt(resourceCount++);
+ if (this.identifier is 0) {
+ WebDataSource dataSource = new WebDataSource(dataSourceID);
+ WebFrame frame = dataSource.webFrame();
+ if (frame.id is webView.mainFrame().id) this.identifier = identifier.id;
+ }
+ return identifier.id;
+
+}
+
+int /*long*/ webView_resource_willSendRequest_redirectResponse_fromDataSource(int /*long*/ sender, int /*long*/ identifier, int /*long*/ request, int /*long*/ redirectResponse, int /*long*/ dataSource) {
+ return request;
+}
+
+/* handleNotification */
+
+void handleNotification(int /*long*/ notification) {
+}
+
+/* UIDelegate */
+
+int /*long*/ webView_createWebViewWithRequest(int /*long*/ sender, int /*long*/ request) {
+ WindowEvent newEvent = new WindowEvent(browser);
+ newEvent.display = browser.getDisplay();
+ newEvent.widget = browser;
+ newEvent.required = true;
+ if (openWindowListeners !is null) {
+ for (int i = 0; i < openWindowListeners.length; i++) {
+ openWindowListeners[i].open(newEvent);
+ }
+ }
+ WebView result = null;
+ Browser browser = null;
+ if (newEvent.browser !is null && newEvent.browser.webBrowser instanceof Safari) {
+ browser = newEvent.browser;
+ }
+ if (browser !is null && !browser.isDisposed()) {
+ result = ((Safari)browser.webBrowser).webView;
+ if (request !is 0) {
+ WebFrame mainFrame = webView.mainFrame();
+ mainFrame.loadRequest(new NSURLRequest(request));
+ }
}
+ return result !is null ? result.id : 0;
+}
- /* WebDownload */
+void webViewShow(int /*long*/ sender) {
+ /*
+ * Feature on WebKit. The Safari WebKit expects the application
+ * to create a new Window using the Objective C Cocoa API in response
+ * to UIDelegate.createWebViewWithRequest. The application is then
+ * expected to use Objective C Cocoa API to make this window visible
+ * when receiving the UIDelegate.webViewShow message. For some reason,
+ * a window created with the Carbon API hosting the new browser instance
+ * does not redraw until it has been resized. The fix is to increase the
+ * size of the Shell and restore it to its initial size.
+ */
+ Shell parent = browser.getShell();
+ Point pt = parent.getSize();
+ parent.setSize(pt.x+1, pt.y);
+ parent.setSize(pt.x, pt.y);
+ WindowEvent newEvent = new WindowEvent(browser);
+ newEvent.display = browser.getDisplay();
+ newEvent.widget = browser;
+ if (location !is null) newEvent.location = location;
+ if (size !is null) newEvent.size = size;
+ /*
+ * Feature in Safari. Safari's tool bar contains
+ * the address bar. The address bar is displayed
+ * if the tool bar is displayed. There is no separate
+ * notification for the address bar.
+ * Feature in Safari. The menu bar is always
+ * displayed. There is no notification to hide
+ * the menu bar.
+ */
+ newEvent.addressBar = toolBar;
+ newEvent.menuBar = true;
+ newEvent.statusBar = statusBar;
+ newEvent.toolBar = toolBar;
+ for (int i = 0; i < visibilityWindowListeners.length; i++) {
+ visibilityWindowListeners[i].show(newEvent);
+ }
+ location = null;
+ size = null;
+}
+
+void webView_setFrame(int /*long*/ sender, int /*long*/ frame) {
+ NSRect rect = new NSRect();
+ OS.memmove(rect, frame, NSRect.sizeof);
+ /* convert to DWT system coordinates */
+ Rectangle bounds = browser.getDisplay().getBounds();
+ location = new Point((int)rect.x, bounds.height - (int)rect.y - (int)rect.height);
+ size = new Point((int)rect.width, (int)rect.height);
+}
+
+void webViewFocus(int /*long*/ sender) {
+}
+
+void webViewUnfocus(int /*long*/ sender) {
+}
+
+void webView_runJavaScriptAlertPanelWithMessage(int /*long*/ sender, int /*long*/ messageID) {
+ NSString message = new NSString(messageID);
+ String text = message.getString();
- void download_decideDestinationWithSuggestedFilename (int downloadId, int filename)
- {
- NSString String = new NSString(filename);
- char[] buffer = new char[String.length()];
- String.getCharacters_(buffer);
- String name = new String(buffer);
- FileDialog dialog = new FileDialog(browser.getShell(), DWT.SAVE);
- dialog.setText(DWT.getMessage("DWT_FileDownload")); //$NON-NLS-1$
- dialog.setFileName(name);
- String path = dialog.open();
- NSURLDownload download = new NSURLDownload(downloadId);
- if (path is null)
- {
- /* cancel pressed */
- download.cancel();
- return;
+ MessageBox messageBox = new MessageBox(browser.getShell(), DWT.OK | DWT.ICON_WARNING);
+ messageBox.setText("Javascript"); //$NON-NLS-1$
+ messageBox.setMessage(text);
+ messageBox.open();
+}
+
+int webView_runJavaScriptConfirmPanelWithMessage(int /*long*/ sender, int /*long*/ messageID) {
+ NSString message = new NSString(messageID);
+ String text = message.getString();
+
+ MessageBox messageBox = new MessageBox(browser.getShell(), DWT.OK | DWT.CANCEL | DWT.ICON_QUESTION);
+ messageBox.setText("Javascript"); //$NON-NLS-1$
+ messageBox.setMessage(text);
+ return messageBox.open() is DWT.OK ? 1 : 0;
+}
+
+void webView_runOpenPanelForFileButtonWithResultListener(int /*long*/ sender, int /*long*/ resultListenerID) {
+ FileDialog dialog = new FileDialog(browser.getShell(), DWT.NONE);
+ String result = dialog.open();
+ WebOpenPanelResultListener resultListener = new WebOpenPanelResultListener(resultListenerID);
+ if (result is null) {
+ resultListener.cancel();
+ return;
+ }
+ resultListener.chooseFilename(NSString.stringWith(result));
+}
+
+void webViewClose(int /*long*/ sender) {
+ Shell parent = browser.getShell();
+ WindowEvent newEvent = new WindowEvent(browser);
+ newEvent.display = browser.getDisplay();
+ newEvent.widget = browser;
+ for (int i = 0; i < closeWindowListeners.length; i++) {
+ closeWindowListeners[i].close(newEvent);
+ }
+ browser.dispose();
+ if (parent.isDisposed()) return;
+ /*
+ * Feature on WebKit. The Safari WebKit expects the application
+ * to create a new Window using the Objective C Cocoa API in response
+ * to UIDelegate.createWebViewWithRequest. The application is then
+ * expected to use Objective C Cocoa API to make this window visible
+ * when receiving the UIDelegate.webViewShow message. For some reason,
+ * a window created with the Carbon API hosting the new browser instance
+ * does not redraw until it has been resized. The fix is to increase the
+ * size of the Shell and restore it to its initial size.
+ */
+ Point pt = parent.getSize();
+ parent.setSize(pt.x+1, pt.y);
+ parent.setSize(pt.x, pt.y);
+}
+
+int /*long*/ webView_contextMenuItemsForElement_defaultMenuItems(int /*long*/ sender, int /*long*/ element, int /*long*/ defaultMenuItems) {
+ Point pt = browser.getDisplay().getCursorLocation();
+ Event event = new Event();
+ event.x = pt.x;
+ event.y = pt.y;
+ browser.notifyListeners(DWT.MenuDetect, event);
+ Menu menu = browser.getMenu();
+ if (!event.doit) return 0;
+ if (menu !is null && !menu.isDisposed()) {
+ if (event.x !is pt.x || event.y !is pt.y) {
+ menu.setLocation(event.x, event.y);
}
- download.setDestination(NSString.StringWith(path), true);
+ menu.setVisible(true);
+ return 0;
+ }
+ return defaultMenuItems;
+}
+
+void webView_setStatusBarVisible(int /*long*/ sender, bool visible) {
+ /* Note. Webkit only emits the notification when the status bar should be hidden. */
+ statusBar = visible;
+}
+
+void webView_setStatusText(int /*long*/ sender, int /*long*/ textID) {
+ NSString text = new NSString(textID);
+ int length = (int)/*64*/text.length();
+ if (length is 0) return;
+
+ StatusTextEvent statusText = new StatusTextEvent(browser);
+ statusText.display = browser.getDisplay();
+ statusText.widget = browser;
+ statusText.text = text.getString();
+ for (int i = 0; i < statusTextListeners.length; i++) {
+ statusTextListeners[i].changed(statusText);
+ }
+}
+
+void webView_setResizable(int /*long*/ sender, bool visible) {
+}
+
+void webView_setToolbarsVisible(int /*long*/ sender, bool visible) {
+ /* Note. Webkit only emits the notification when the tool bar should be hidden. */
+ toolBar = visible;
+}
+
+void webView_mouseDidMoveOverElement_modifierFlags (int /*long*/ sender, int /*long*/ elementInformationID, int /*long*/ modifierFlags) {
+ if (elementInformationID is 0) return;
+
+ NSString key = NSString.stringWith(WebElementLinkURLKey);
+ NSDictionary elementInformation = new NSDictionary(elementInformationID);
+ id value = elementInformation.valueForKey(key);
+ if (value is null) {
+ /* not currently over a link */
+ if (lastHoveredLinkURL is null) return;
+ lastHoveredLinkURL = null;
+ StatusTextEvent statusText = new StatusTextEvent(browser);
+ statusText.display = browser.getDisplay();
+ statusText.widget = browser;
+ statusText.text = ""; //$NON-NLS-1$
+ for (int i = 0; i < statusTextListeners.length; i++) {
+ statusTextListeners[i].changed(statusText);
+ }
+ return;
}
- /* DOMEventListener */
+ NSString url = new NSURL(value.id).absoluteString();
+ int length = (int)/*64*/url.length();
+ String urlString;
+ if (length is 0) {
+ urlString = ""; //$NON-NLS-1$
+ } else {
+ urlString = url.getString();
+ }
+ if (urlString.equals(lastHoveredLinkURL)) return;
- void handleEvent (int evtId)
- {
- DOMEvent evt = new DOMEvent(evtId);
- NSString String = evt.type();
- char[] buffer = new char[String.length()];
- String.getCharacters_(buffer);
- String type = new String(buffer);
+ lastHoveredLinkURL = urlString;
+ StatusTextEvent statusText = new StatusTextEvent(browser);
+ statusText.display = browser.getDisplay();
+ statusText.widget = browser;
+ statusText.text = urlString;
+ for (int i = 0; i < statusTextListeners.length; i++) {
+ statusTextListeners[i].changed(statusText);
+ }
+}
- if (DOMEVENT_KEYDOWN.opEquals(type) || DOMEVENT_KEYUP.opEquals(type))
- {
- DOMKeyboardEvent event = new DOMKeyboardEvent(evtId);
+void webView_printFrameView (int /*long*/ sender, int /*long*/ frameViewID) {
+ WebFrameView view = new WebFrameView(frameViewID);
+ bool viewPrint = view.documentViewShouldHandlePrint();
+ if (viewPrint) {
+ view.printDocumentView();
+ return;
+ }
+ NSPrintInfo info = NSPrintInfo.sharedPrintInfo();
+ NSPrintOperation operation = view.printOperationWithPrintInfo(info);
+ if (operation !is null) operation.runOperation();
+}
+
+/* PolicyDelegate */
- bool ctrl = event.ctrlKey();
- bool shift = event.shiftKey();
- bool alt = event.altKey();
- bool meta = event.metaKey();
- int keyCode = event.keyCode();
- int charCode = event.charCode();
+void webView_decidePolicyForMIMEType_request_frame_decisionListener(int /*long*/ sender, int /*long*/ type, int /*long*/ request, int /*long*/ frame, int /*long*/ listenerID) {
+ bool canShow = WebView.canShowMIMEType(new NSString(type));
+ WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID);
+ if (canShow) {
+ listener.use();
+ } else {
+ listener.download();
+ }
+}
+
+void webView_decidePolicyForNavigationAction_request_frame_decisionListener(int /*long*/ sender, int /*long*/ actionInformation, int /*long*/ request, int /*long*/ frame, int /*long*/ listenerID) {
+ NSURL url = new NSURLRequest(request).URL();
+ WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID);
+ if (url is null) {
+ /* indicates that a URL with an invalid format was specified */
+ listener.ignore();
+ return;
+ }
+ NSString s = url.absoluteString();
+ String url2 = s.getString();
+ /*
+ * If the URI indicates that the page is being rendered from memory
+ * (via setText()) then set it to about:blank to be consistent with IE.
+ */
+ if (url2.equals (URI_FROMMEMORY)) url2 = ABOUT_BLANK;
- Event keyEvent = new Event();
- keyEvent.widget = browser;
- if (DOMEVENT_KEYDOWN.opEquals(type))
- {
- keyEvent.type = DWT.KeyDown;
- }
- else
- {
- keyEvent.type = DWT.KeyUp;
- }
- keyEvent.keyCode = translateKey(keyCode);
- keyEvent.character = cast(char) charCode;
- keyEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0);
- browser.notifyListeners(keyEvent.type, keyEvent);
- if (!keyEvent.doit)
- {
- event.preventDefault();
- }
- return;
+ LocationEvent newEvent = new LocationEvent(browser);
+ newEvent.display = browser.getDisplay();
+ newEvent.widget = browser;
+ newEvent.location = url2;
+ newEvent.doit = true;
+ if (locationListeners !is null) {
+ changingLocation = true;
+ for (int i = 0; i < locationListeners.length; i++) {
+ locationListeners[i].changing(newEvent);
}
+ changingLocation = false;
+ }
+ if (newEvent.doit) {
+ listener.use();
+ } else {
+ listener.ignore();
+ }
+ if (html !is null && !browser.isDisposed()) {
+ String html = this.html;
+ this.html = null;
+ _setText(html);
+ }
+}
+
+void webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener(int /*long*/ sender, int /*long*/ actionInformation, int /*long*/ request, int /*long*/ frameName, int /*long*/ listenerID) {
+ WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID);
+ listener.use();
+}
- if (DOMEVENT_MOUSEWHEEL.opEquals(type))
- {
- DOMWheelEvent event = new DOMWheelEvent(evtId);
- int clientX = event.clientX();
- int clientY = event.clientY();
- int delta = event.wheelDelta();
- bool ctrl = event.ctrlKey();
- bool shift = event.shiftKey();
- bool alt = event.altKey();
- bool meta = event.metaKey();
- Event mouseEvent = new Event();
- mouseEvent.type = DWT.MouseWheel;
- mouseEvent.widget = browser;
- mouseEvent.x = clientX;
- mouseEvent.y = clientY;
- mouseEvent.count = delta / 120;
- mouseEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0);
- browser.notifyListeners(mouseEvent.type, mouseEvent);
- return;
- }
+void webView_unableToImplementPolicyWithError_frame(int /*long*/ sender, int /*long*/ error, int /*long*/ frame) {
+}
+
+/* WebDownload */
- /* mouse event */
-
- DOMMouseEvent event = new DOMMouseEvent(evtId);
+void download_decideDestinationWithSuggestedFilename(int /*long*/ downloadId, int /*long*/ filename) {
+ NSString string = new NSString(filename);
+ String name = string.getString();
+ FileDialog dialog = new FileDialog(browser.getShell(), DWT.SAVE);
+ dialog.setText(DWT.getMessage ("DWT_FileDownload")); //$NON-NLS-1$
+ dialog.setFileName(name);
+ String path = dialog.open();
+ NSURLDownload download = new NSURLDownload(downloadId);
+ if (path is null) {
+ /* cancel pressed */
+ download.cancel();
+ return;
+ }
+ download.setDestination(NSString.stringWith(path), true);
+}
- int clientX = event.clientX();
- int clientY = event.clientY();
- int detail = event.detail();
- int button = event.button();
+/* DOMEventListener */
+
+void handleEvent(int /*long*/ evtId) {
+ NSString string = new NSString(OS.objc_msgSend(evtId, OS.sel_type));
+ String type = string.getString();
+
+ if (DOMEVENT_KEYDOWN.equals(type) || DOMEVENT_KEYUP.equals(type)) {
+ DOMKeyboardEvent event = new DOMKeyboardEvent(evtId);
+
bool ctrl = event.ctrlKey();
bool shift = event.shiftKey();
bool alt = event.altKey();
bool meta = event.metaKey();
+ int keyCode = event.keyCode();
+ int charCode = event.charCode();
- Event mouseEvent = new Event();
- mouseEvent.widget = browser;
- mouseEvent.x = clientX;
- mouseEvent.y = clientY;
- mouseEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0);
- if (DOMEVENT_MOUSEDOWN.opEquals(type))
- {
- mouseEvent.type = DWT.MouseDown;
- mouseEvent.button = button + 1;
- mouseEvent.count = detail;
+ Event keyEvent = new Event();
+ keyEvent.widget = browser;
+ if (DOMEVENT_KEYDOWN.equals(type)) {
+ keyEvent.type = DWT.KeyDown;
+ } else {
+ keyEvent.type = DWT.KeyUp;
+ }
+ keyEvent.keyCode = translateKey(keyCode);
+ keyEvent.character = (char)charCode;
+ keyEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0);
+ browser.notifyListeners(keyEvent.type, keyEvent);
+ if (!keyEvent.doit) {
+ event.preventDefault();
}
- else if (DOMEVENT_MOUSEUP.opEquals(type))
- {
- mouseEvent.type = DWT.MouseUp;
- mouseEvent.button = button + 1;
- mouseEvent.count = detail;
- switch (mouseEvent.button)
- {
- case 1:
- mouseEvent.stateMask |= DWT.BUTTON1;
- break;
- case 2:
- mouseEvent.stateMask |= DWT.BUTTON2;
- break;
- case 3:
- mouseEvent.stateMask |= DWT.BUTTON3;
- break;
- case 4:
- mouseEvent.stateMask |= DWT.BUTTON4;
- break;
- case 5:
- mouseEvent.stateMask |= DWT.BUTTON5;
- break;
- }
+ return;
+ }
+
+ if (DOMEVENT_MOUSEWHEEL.equals(type)) {
+ DOMWheelEvent event = new DOMWheelEvent(evtId);
+ int clientX = event.clientX();
+ int clientY = event.clientY();
+ int delta = event.wheelDelta();
+ bool ctrl = event.ctrlKey();
+ bool shift = event.shiftKey();
+ bool alt = event.altKey();
+ bool meta = event.metaKey();
+ Event mouseEvent = new Event();
+ mouseEvent.type = DWT.MouseWheel;
+ mouseEvent.widget = browser;
+ mouseEvent.x = clientX; mouseEvent.y = clientY;
+ mouseEvent.count = delta / 120;
+ mouseEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0);
+ browser.notifyListeners (mouseEvent.type, mouseEvent);
+ return;
+ }
+
+ /* mouse event */
+
+ DOMMouseEvent event = new DOMMouseEvent(evtId);
+
+ int clientX = event.clientX();
+ int clientY = event.clientY();
+ int detail = event.detail();
+ int button = event.button();
+ bool ctrl = event.ctrlKey();
+ bool shift = event.shiftKey();
+ bool alt = event.altKey();
+ bool meta = event.metaKey();
+
+ Event mouseEvent = new Event ();
+ mouseEvent.widget = browser;
+ mouseEvent.x = clientX; mouseEvent.y = clientY;
+ mouseEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0);
+ if (DOMEVENT_MOUSEDOWN.equals (type)) {
+ mouseEvent.type = DWT.MouseDown;
+ mouseEvent.button = button + 1;
+ mouseEvent.count = detail;
+ } else if (DOMEVENT_MOUSEUP.equals (type)) {
+ mouseEvent.type = DWT.MouseUp;
+ mouseEvent.button = button + 1;
+ mouseEvent.count = detail;
+ switch (mouseEvent.button) {
+ case 1: mouseEvent.stateMask |= DWT.BUTTON1; break;
+ case 2: mouseEvent.stateMask |= DWT.BUTTON2; break;
+ case 3: mouseEvent.stateMask |= DWT.BUTTON3; break;
+ case 4: mouseEvent.stateMask |= DWT.BUTTON4; break;
+ case 5: mouseEvent.stateMask |= DWT.BUTTON5; break;
}
- else if (DOMEVENT_MOUSEMOVE.opEquals(type))
- {
- /*
- * Bug in Safari. Spurious and redundant mousemove events are received in
- * various contexts, including following every MouseUp. The workaround is
- * to not fire MouseMove events whose x and y values match the last MouseMove
- */
- if (mouseEvent.x is lastMouseMoveX && mouseEvent.y is lastMouseMoveY)
- return;
- mouseEvent.type = DWT.MouseMove;
- lastMouseMoveX = mouseEvent.x;
- lastMouseMoveY = mouseEvent.y;
- }
+ } else if (DOMEVENT_MOUSEMOVE.equals (type)) {
+ /*
+ * Bug in Safari. Spurious and redundant mousemove events are received in
+ * various contexts, including following every MouseUp. The workaround is
+ * to not fire MouseMove events whose x and y values match the last MouseMove
+ */
+ if (mouseEvent.x is lastMouseMoveX && mouseEvent.y is lastMouseMoveY) return;
+ mouseEvent.type = DWT.MouseMove;
+ lastMouseMoveX = mouseEvent.x; lastMouseMoveY = mouseEvent.y;
+ }
- browser.notifyListeners(mouseEvent.type, mouseEvent);
- if (detail is 2 && DOMEVENT_MOUSEDOWN.opEquals(type))
- {
- mouseEvent = new Event();
- mouseEvent.widget = browser;
- mouseEvent.x = clientX;
- mouseEvent.y = clientY;
- mouseEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0);
- mouseEvent.type = DWT.MouseDoubleClick;
- mouseEvent.button = button + 1;
- mouseEvent.count = detail;
- browser.notifyListeners(mouseEvent.type, mouseEvent);
- }
+ browser.notifyListeners (mouseEvent.type, mouseEvent);
+ if (detail is 2 && DOMEVENT_MOUSEDOWN.equals (type)) {
+ mouseEvent = new Event ();
+ mouseEvent.widget = browser;
+ mouseEvent.x = clientX; mouseEvent.y = clientY;
+ mouseEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0);
+ mouseEvent.type = DWT.MouseDoubleClick;
+ mouseEvent.button = button + 1;
+ mouseEvent.count = detail;
+ browser.notifyListeners (mouseEvent.type, mouseEvent);
}
}
+}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/SimpleEnumerator.d
--- a/dwt/browser/SimpleEnumerator.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/SimpleEnumerator.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2003, 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/StatusTextEvent.d
--- a/dwt/browser/StatusTextEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/StatusTextEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.StatusTextEvent;
@@ -24,6 +24,8 @@
* The status text is typically displayed in the status bar of
* a browser application.
*
+ * @see Sample code and further information
+ *
* @since 3.0
*/
public class StatusTextEvent : TypedEvent {
@@ -37,14 +39,14 @@
}
/**
- * Returns a String containing a concise, human-readable
+ * Returns a string containing a concise, human-readable
* description of the receiver.
*
- * @return a String representation of the event
+ * @return a string representation of the event
*/
public String toString () {
- String String = super.toString();
- return String.substring(0, String.length() - 1) // remove trailing '}'
+ String string = super.toString();
+ return string.substring(0, string.length() - 1) // remove trailing '}'
+ " text=" + text + "}";
}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/StatusTextListener.d
--- a/dwt/browser/StatusTextListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/StatusTextListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.StatusTextListener;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/TitleEvent.d
--- a/dwt/browser/TitleEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/TitleEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.TitleEvent;
@@ -23,6 +23,8 @@
* {@link TitleListener}'s when the title of the current document
* is available or when it is modified.
*
+ * @see Sample code and further information
+ *
* @since 3.0
*/
public class TitleEvent : TypedEvent {
@@ -36,14 +38,14 @@
}
/**
- * Returns a String containing a concise, human-readable
+ * Returns a string containing a concise, human-readable
* description of the receiver.
*
- * @return a String representation of the event
+ * @return a string representation of the event
*/
public String toString () {
String str = super.toString();
- return str.substring(0, String.length() - 1) // remove trailing '}'
+ return str.substring(0, string.length() - 1) // remove trailing '}'
+ " title=" + title + "}";
}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/TitleListener.d
--- a/dwt/browser/TitleListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/TitleListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.TitleListener;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/VisibilityWindowAdapter.d
--- a/dwt/browser/VisibilityWindowAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/VisibilityWindowAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.VisibilityWindowAdapter;
@@ -26,13 +26,15 @@
* interested in.
*
*
+ * @see Sample code and further information
+ *
* @since 3.0
*/
public abstract class VisibilityWindowAdapter : VisibilityWindowListener {
- public void hide (WindowEvent event) {
- }
+public void hide(WindowEvent event) {
+}
- public void show (WindowEvent event) {
- }
+public void show(WindowEvent event) {
}
+}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/VisibilityWindowListener.d
--- a/dwt/browser/VisibilityWindowListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/VisibilityWindowListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.VisibilityWindowListener;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/WebBrowser.d
--- a/dwt/browser/WebBrowser.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/WebBrowser.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.WebBrowser;
@@ -240,6 +240,8 @@
public abstract bool forward ();
+public abstract String getBrowserType ();
+
public abstract String getText ();
public abstract String getUrl ();
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/WindowCreator2.d
--- a/dwt/browser/WindowCreator2.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/WindowCreator2.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2003, 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/browser/WindowEvent.d
--- a/dwt/browser/WindowEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/WindowEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2003, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.browser.WindowEvent;
@@ -123,6 +123,7 @@
* @see CloseWindowListener
* @see OpenWindowListener
* @see VisibilityWindowListener
+ * @see Sample code and further information
*
* @since 3.0
*/
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/ByteArrayTransfer.d
--- a/dwt/dnd/ByteArrayTransfer.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 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
- *******************************************************************************/
-module dwt.dnd;
-
-
-/**
- * The class ByteArrayTransfer
provides a platform specific
- * mechanism for converting a java byte[]
to a platform
- * specific representation of the byte array and vice versa. See
- * Transfer
for additional information.
- *
- * ByteArrayTransfer
is never used directly but is sub-classed
- * by transfer agents that convert between data in a java format such as a
- * String
and a platform specific byte array.
- *
- *
If the data you are converting does not map to a
- * byte[]
, you should sub-class Transfer
directly
- * and do your own mapping to a platform data type.
- *
- * The following snippet shows a subclass of ByteArrayTransfer that transfers
- * data defined by the class MyType
.
- *
- *
- * public class MyType {
- * public String fileName;
- * public long fileLength;
- * public long lastModified;
- * }
- *
- *
- *
- * public class MyTypeTransfer : ByteArrayTransfer {
- *
- * private static final String MYTYPENAME = "my_type_name";
- * private static final int MYTYPEID = registerType(MYTYPENAME);
- * private static MyTypeTransfer _instance = new MyTypeTransfer();
- *
- * private MyTypeTransfer() {}
- *
- * public static MyTypeTransfer getInstance () {
- * return _instance;
- * }
- * public void javaToNative (Object object, TransferData transferData) {
- * if (object is null || !(object instanceof MyType[])) return;
- *
- * if (isSupportedType(transferData)) {
- * MyType[] myTypes = (MyType[]) object;
- * try {
- * // write data to a byte array and then ask super to convert to pMedium
- * ByteArrayOutputStream out = new ByteArrayOutputStream();
- * DataOutputStream writeOut = new DataOutputStream(out);
- * for (int i = 0, length = myTypes.length; i < length; i++){
- * byte[] buffer = myTypes[i].fileName.getBytes();
- * writeOut.writeInt(buffer.length);
- * writeOut.write(buffer);
- * writeOut.writeLong(myTypes[i].fileLength);
- * writeOut.writeLong(myTypes[i].lastModified);
- * }
- * byte[] buffer = out.toByteArray();
- * writeOut.close();
- *
- * super.javaToNative(buffer, transferData);
- *
- * } catch (IOException e) {
- * }
- * }
- * }
- * public Object nativeToJava(TransferData transferData){
- *
- * if (isSupportedType(transferData)) {
- *
- * byte[] buffer = (byte[])super.nativeToJava(transferData);
- * if (buffer is null) return null;
- *
- * MyType[] myData = new MyType[0];
- * try {
- * ByteArrayInputStream in = new ByteArrayInputStream(buffer);
- * DataInputStream readIn = new DataInputStream(in);
- * while(readIn.available() > 20) {
- * MyType datum = new MyType();
- * int size = readIn.readInt();
- * byte[] name = new byte[size];
- * readIn.read(name);
- * datum.fileName = new String(name);
- * datum.fileLength = readIn.readLong();
- * datum.lastModified = readIn.readLong();
- * MyType[] newMyData = new MyType[myData.length + 1];
- * System.arraycopy(myData, 0, newMyData, 0, myData.length);
- * newMyData[myData.length] = datum;
- * myData = newMyData;
- * }
- * readIn.close();
- * } catch (IOException ex) {
- * return null;
- * }
- * return myData;
- * }
- *
- * return null;
- * }
- * protected String[] getTypeNames(){
- * return new String[]{MYTYPENAME};
- * }
- * protected int[] getTypeIds(){
- * return new int[] {MYTYPEID};
- * }
- * }
- *
- */
-public abstract class ByteArrayTransfer : Transfer {
-
-public TransferData[] getSupportedTypes() {
- int[] types = getTypeIds();
- TransferData[] data = new TransferData[types.length];
- for (int i = 0; i < types.length; i++) {
- data[i] = new TransferData();
- data[i].type = types[i];
- }
- return data;
-}
-
-public bool isSupportedType(TransferData transferData){
- if (transferData is null) return false;
- int[] types = getTypeIds();
- for (int i = 0; i < types.length; i++) {
- if (transferData.type is types[i]) return true;
- }
- return false;
-}
-
-/**
- * This implementation of javaToNative
converts a java
- * byte[]
to a platform specific representation. For additional
- * information see Transfer#javaToNative
.
- *
- * @see Transfer#javaToNative
- *
- * @param object a java byte[]
containing the data to be converted
- * @param transferData an empty TransferData
object; this
- * object will be filled in on return with the platform specific format of the data
- */
-protected void javaToNative (Object object, TransferData transferData) {
- if (!checkByteArray(object) && !isSupportedType(transferData)) {
- DND.error(DND.ERROR_INVALID_DATA);
- }
- byte[] orig = (byte[])object;
- byte[] buffer = new byte[orig.length];
- System.arraycopy(orig, 0, buffer, 0, orig.length);
- transferData.data = new byte[1][];
- transferData.data[0] = buffer;
- transferData.result = 0;
-}
-
-/**
- * This implementation of nativeToJava
converts a platform specific
- * representation of a byte array to a java byte[]
.
- * For additional information see Transfer#nativeToJava
.
- *
- * @see Transfer#nativeToJava
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java byte[]
containing the converted data if the
- * conversion was successful; otherwise null
- */
-protected Object nativeToJava(TransferData transferData) {
- if (!isSupportedType(transferData) || transferData.data is null) return null;
- if (transferData.data.length is 0 || transferData.data[0].length is 0) return null;
- return transferData.data[0];
-}
-bool checkByteArray(Object object) {
- return (object !is null && object instanceof byte[] && ((byte[])object).length > 0);
-}
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/Clipboard.d
--- a/dwt/dnd/Clipboard.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/Clipboard.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -8,23 +8,37 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.Clipboard;
+
+import dwt.dwthelper.utils;
-import dwt.*;
-import dwt.widgets.*;
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSMutableArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPasteboard;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
import dwt.internal.cocoa.OS;
+import dwt.widgets.Display;
/**
* The Clipboard
provides a mechanism for transferring data from one
* application to another or within an application.
*
* IMPORTANT: This class is not intended to be subclassed.
+ *
+ * @see Clipboard snippets
+ * @see DWT Example: ClipboardExample
+ * @see Sample code and further information
*/
public class Clipboard {
Display display;
- int scrap = 0;
/**
* Constructs a new instance of this class. Creating an instance of a Clipboard
@@ -41,7 +55,7 @@
* @see Clipboard#dispose
* @see Clipboard#checkSubclass
*/
-public this(Display display) {
+public Clipboard(Display display) {
checkSubclass ();
if (display is null) {
display = Display.getCurrent();
@@ -85,7 +99,7 @@
protected void checkSubclass () {
String name = getClass().getName ();
String validName = Clipboard.class.getName();
- if (!validName.opEquals(name)) {
+ if (!validName.equals(name)) {
DND.error (DWT.ERROR_INVALID_SUBCLASS);
}
}
@@ -164,14 +178,9 @@
*/
public void clearContents(int clipboards) {
checkWidget();
- if ((clipboards & DND.CLIPBOARD) is 0 || scrap is 0) return;
- int oldScrap = scrap;
- scrap = 0;
- int[] currentScrap = new int[1];
- if (OS.GetCurrentScrap(currentScrap) !is OS.noErr) return;
- if (currentScrap[0] is oldScrap) {
- OS.ClearCurrentScrap();
- }
+ if ((clipboards & DND.CLIPBOARD) is 0) return;
+ NSPasteboard pasteboard = NSPasteboard.generalPasteboard();
+ pasteboard.declareTypes(NSMutableArray.arrayWithCapacity(0), null);
}
/**
@@ -203,10 +212,10 @@
*
* Clipboard clipboard = new Clipboard(display);
* TextTransfer textTransfer = TextTransfer.getInstance();
- * String textData = cast(String)clipboard.getContents(textTransfer);
+ * String textData = (String)clipboard.getContents(textTransfer);
* if (textData !is null) System.out.println("Text is "+textData);
* RTFTransfer rtfTransfer = RTFTransfer.getInstance();
- * String rtfData = cast(String)clipboard.getContents(rtfTransfer);
+ * String rtfData = (String)clipboard.getContents(rtfTransfer);
* if (rtfData !is null) System.out.println("RTF Text is "+rtfData);
* clipboard.dispose();
*
@@ -239,10 +248,10 @@
*
* Clipboard clipboard = new Clipboard(display);
* TextTransfer textTransfer = TextTransfer.getInstance();
- * String textData = cast(String)clipboard.getContents(textTransfer);
+ * String textData = (String)clipboard.getContents(textTransfer);
* if (textData !is null) System.out.println("Text is "+textData);
* RTFTransfer rtfTransfer = RTFTransfer.getInstance();
- * String rtfData = cast(String)clipboard.getContents(rtfTransfer, DND.CLIPBOARD);
+ * String rtfData = (String)clipboard.getContents(rtfTransfer, DND.CLIPBOARD);
* if (rtfData !is null) System.out.println("RTF Text is "+rtfData);
* clipboard.dispose();
*
@@ -275,26 +284,32 @@
checkWidget();
if (transfer is null) DND.error(DWT.ERROR_NULL_ARGUMENT);
if ((clipboards & DND.CLIPBOARD) is 0) return null;
- int[] scrap = new int[1];
- if (OS.GetCurrentScrap(scrap) !is OS.noErr) return null;
- int[] typeIds = transfer.getTypeIds();
- int[] size = new int[1];
- // get data from system clipboard
- for (int i=0; i 0) {
- byte[] buffer = new byte[size[0]];
- if (OS.GetScrapFlavorData(scrap[0], type, size, buffer) is OS.noErr) {
- TransferData tdata = new TransferData();
- tdata.type = type;
- tdata.data = new byte[1][];
- tdata.data[0] = buffer;
- return transfer.nativeToJava(tdata);
- }
+ NSPasteboard pasteboard = NSPasteboard.generalPasteboard();
+ String[] typeNames = transfer.getTypeNames();
+ NSMutableArray types = NSMutableArray.arrayWithCapacity(typeNames.length);
+ for (int i = 0; i < typeNames.length; i++) {
+ types.addObject(NSString.stringWith(typeNames[i]));
+ }
+ NSString type = pasteboard.availableTypeFromArray(types);
+ if (type !is null) {
+ TransferData tdata = new TransferData();
+ tdata.type = Transfer.registerType(type.getString());
+ if (type.isEqual(OS.NSStringPboardType) ||
+ type.isEqual(OS.NSRTFPboardType) ||
+ type.isEqual(OS.NSHTMLPboardType)) {
+ tdata.data = pasteboard.stringForType(type);
+ } else if (type.isEqual(OS.NSFilenamesPboardType)) {
+ tdata.data = new NSArray(pasteboard.propertyListForType(type).id);
+ } else if (type.isEqual(OS.NSURLPboardType)) {
+ tdata.data = NSURL.URLFromPasteboard(pasteboard);
+ } else {
+ tdata.data = pasteboard.dataForType(type);
+ }
+ if (tdata.data !is null) {
+ return transfer.nativeToJava(tdata);
}
}
- return null; // No data available for this transfer
+ return null;
}
/**
@@ -435,30 +450,31 @@
}
}
if ((clipboards & DND.CLIPBOARD) is 0) return;
- if (OS.ClearCurrentScrap() !is OS.noErr) {
- DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
- }
- scrap = 0;
- int[] currentScrap = new int[1];
- if (OS.GetCurrentScrap(currentScrap) !is OS.noErr) {
+ NSPasteboard pasteboard = NSPasteboard.generalPasteboard();
+ if (pasteboard is null) {
DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
}
- scrap = currentScrap[0];
- // copy data directly over to System clipboard (not deferred)
+ pasteboard.declareTypes(NSMutableArray.arrayWithCapacity(0), null);
for (int i=0; i> 24));
- sb.append(cast(wchar)((type & 0x00ff0000) >> 16));
- sb.append(cast(wchar)((type & 0x0000ff00) >> 8));
- sb.append(cast(wchar)((type & 0x000000ff) >> 0));
- names[i] = sb.toString();
+ NSPasteboard pasteboard = NSPasteboard.generalPasteboard();
+ NSArray types = pasteboard.types();
+ int count = (int)/*64*/types.count();
+ String[] result = new String[count];
+ for (int i = 0; i < count; i++) {
+ result[i] = new NSString(types.objectAtIndex(i)).getString();
}
- return names;
-}
-
-int[] _getAvailableTypes() {
- int[] types = new int[0];
- int[] scrap = new int[1];
- if (OS.GetCurrentScrap(scrap) !is OS.noErr) return types;
- int[] count = new int[1];
- if (OS.GetScrapFlavorCount(scrap[0], count) !is OS.noErr || count[0] is 0) return types;
- int[] info = new int[count[0] * 2];
- if (OS.GetScrapFlavorInfoList(scrap[0], count, info) !is OS.noErr) return types;
- types = new int[count[0]];
- for (int i= 0; i < count [0]; i++) {
- types[i] = info[i*2];
- }
- return types;
+ return result;
}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DND.d
--- a/dwt/dnd/DND.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DND.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -8,16 +8,21 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DND;
+
+import dwt.dwthelper.utils;
-import dwt.*;
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
/**
*
* Class DND contains all the constants used in defining a
* DragSource or a DropTarget.
*
+ * @see Sample code and further information
*/
public class DND {
@@ -194,7 +199,7 @@
public static final int ERROR_INVALID_DATA = 2003;
/**
- * DropTarget Key: The String constant for looking up the drop target
+ * DropTarget Key: The string constant for looking up the drop target
* for a control using getData(String)
. When a drop target
* is created for a control, it is stored as a property in the control
* using setData(String, Object)
.
@@ -204,7 +209,7 @@
public static final String DROP_TARGET_KEY = "DropTarget"; //$NON-NLS-1$
/**
- * DragSource Key: The String constant for looking up the drag source
+ * DragSource Key: The string constant for looking up the drag source
* for a control using getData(String)
. When a drag source
* is created for a control, it is stored as a property in the control
* using setData(String, Object)
.
@@ -236,9 +241,9 @@
*
* - java.lang.IllegalArgumentException
* - thrown whenever one of the API methods is invoked with an illegal argument
- * - dwt.DWTException (: java.lang.RuntimeException)
+ * - dwt.DWTException (extends java.lang.RuntimeException)
* - thrown whenever a recoverable error happens internally in DWT
- * - dwt.DWTError (: java.lang.Error)
+ * - dwt.DWTError (extends java.lang.Error)
* - thrown whenever a non-recoverable error happens internally in DWT
*
* This method provides the logic which maps between error codes
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DNDEvent.d
--- a/dwt/dnd/DNDEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DNDEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -8,16 +8,20 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DNDEvent;
+
+import dwt.dwthelper.utils;
-import dwt.graphics.*;
-import dwt.widgets.*;
+import dwt.graphics.Image;
+import dwt.widgets.Event;
-class DNDEvent : Event {
+class DNDEvent extends Event {
public TransferData dataType;
public TransferData[] dataTypes;
public int operations;
public int feedback;
public Image image;
+ public int offsetX;
+ public int offsetY;
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DNDListener.d
--- a/dwt/dnd/DNDListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DNDListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -8,111 +8,115 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DNDListener;
+
+import dwt.dwthelper.utils;
-import dwt.internal.*;
-import dwt.widgets.*;
+import dwt.internal.DWTEventListener;
+import dwt.widgets.Event;
+import dwt.widgets.TypedListener;
+import dwt.widgets.Widget;
-class DNDListener : TypedListener {
+class DNDListener extends TypedListener {
Widget dndWidget;
/**
* DNDListener constructor comment.
* @param listener dwt.internal.DWTEventListener
*/
-this(DWTEventListener listener) {
+DNDListener(DWTEventListener listener) {
super(listener);
}
public void handleEvent (Event e) {
switch (e.type) {
case DND.DragStart: {
- DragSourceEvent event = new DragSourceEvent(cast(DNDEvent)e);
- DragSourceEffect sourceEffect = (cast(DragSource) dndWidget).getDragSourceEffect();
+ DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+ DragSourceEffect sourceEffect = ((DragSource) dndWidget).getDragSourceEffect();
if (sourceEffect !is null) {
sourceEffect.dragStart (event);
}
- (cast(DragSourceListener) eventListener).dragStart (event);
- event.updateEvent(cast(DNDEvent)e);
+ ((DragSourceListener) eventListener).dragStart (event);
+ event.updateEvent((DNDEvent)e);
break;
}
case DND.DragEnd: {
- DragSourceEvent event = new DragSourceEvent(cast(DNDEvent)e);
- DragSourceEffect sourceEffect = (cast(DragSource) dndWidget).getDragSourceEffect();
+ DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+ DragSourceEffect sourceEffect = ((DragSource) dndWidget).getDragSourceEffect();
if (sourceEffect !is null) {
sourceEffect.dragFinished (event);
}
- (cast(DragSourceListener) eventListener).dragFinished (event);
- event.updateEvent(cast(DNDEvent)e);
+ ((DragSourceListener) eventListener).dragFinished (event);
+ event.updateEvent((DNDEvent)e);
break;
}
case DND.DragSetData: {
- DragSourceEvent event = new DragSourceEvent(cast(DNDEvent)e);
- DragSourceEffect sourceEffect = (cast(DragSource) dndWidget).getDragSourceEffect();
+ DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+ DragSourceEffect sourceEffect = ((DragSource) dndWidget).getDragSourceEffect();
if (sourceEffect !is null) {
sourceEffect.dragSetData (event);
}
- (cast(DragSourceListener) eventListener).dragSetData (event);
- event.updateEvent(cast(DNDEvent)e);
+ ((DragSourceListener) eventListener).dragSetData (event);
+ event.updateEvent((DNDEvent)e);
break;
}
case DND.DragEnter: {
- DropTargetEvent event = new DropTargetEvent(cast(DNDEvent)e);
- (cast(DropTargetListener) eventListener).dragEnter (event);
- DropTargetEffect dropEffect = (cast(DropTarget) dndWidget).getDropTargetEffect();
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dragEnter (event);
+ DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
if (dropEffect !is null) {
dropEffect.dragEnter (event);
}
- event.updateEvent(cast(DNDEvent)e);
+ event.updateEvent((DNDEvent)e);
break;
}
case DND.DragLeave: {
- DropTargetEvent event = new DropTargetEvent(cast(DNDEvent)e);
- (cast(DropTargetListener) eventListener).dragLeave (event);
- DropTargetEffect dropEffect = (cast(DropTarget) dndWidget).getDropTargetEffect();
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dragLeave (event);
+ DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
if (dropEffect !is null) {
dropEffect.dragLeave (event);
}
- event.updateEvent(cast(DNDEvent)e);
+ event.updateEvent((DNDEvent)e);
break;
}
case DND.DragOver: {
- DropTargetEvent event = new DropTargetEvent(cast(DNDEvent)e);
- (cast(DropTargetListener) eventListener).dragOver (event);
- DropTargetEffect dropEffect = (cast(DropTarget) dndWidget).getDropTargetEffect();
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dragOver (event);
+ DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
if (dropEffect !is null) {
dropEffect.dragOver (event);
}
- event.updateEvent(cast(DNDEvent)e);
+ event.updateEvent((DNDEvent)e);
break;
}
case DND.Drop: {
- DropTargetEvent event = new DropTargetEvent(cast(DNDEvent)e);
- (cast(DropTargetListener) eventListener).drop (event);
- DropTargetEffect dropEffect = (cast(DropTarget) dndWidget).getDropTargetEffect();
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).drop (event);
+ DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
if (dropEffect !is null) {
dropEffect.drop (event);
}
- event.updateEvent(cast(DNDEvent)e);
+ event.updateEvent((DNDEvent)e);
break;
}
case DND.DropAccept: {
- DropTargetEvent event = new DropTargetEvent(cast(DNDEvent)e);
- (cast(DropTargetListener) eventListener).dropAccept (event);
- DropTargetEffect dropEffect = (cast(DropTarget) dndWidget).getDropTargetEffect();
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dropAccept (event);
+ DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
if (dropEffect !is null) {
dropEffect.dropAccept (event);
}
- event.updateEvent(cast(DNDEvent)e);
+ event.updateEvent((DNDEvent)e);
break;
}
case DND.DragOperationChanged: {
- DropTargetEvent event = new DropTargetEvent(cast(DNDEvent)e);
- (cast(DropTargetListener) eventListener).dragOperationChanged (event);
- DropTargetEffect dropEffect = (cast(DropTarget) dndWidget).getDropTargetEffect();
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dragOperationChanged (event);
+ DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
if (dropEffect !is null) {
dropEffect.dragOperationChanged (event);
}
- event.updateEvent(cast(DNDEvent)e);
+ event.updateEvent((DNDEvent)e);
break;
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DragSource.d
--- a/dwt/dnd/DragSource.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DragSource.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -8,18 +8,38 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DragSource;
+
+import dwt.dwthelper.utils;
+
-
-import dwt.*;
-import dwt.graphics.*;
-import dwt.widgets.*;
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.graphics.Image;
+import dwt.internal.C;
import dwt.internal.Callback;
-import dwt.internal.cocoa.CGPoint;
-import dwt.internal.cocoa.EventRecord;
+import dwt.internal.cocoa.NSApplication;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSMutableArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPasteboard;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
import dwt.internal.cocoa.OS;
-import dwt.internal.cocoa.Point;
-
+import dwt.internal.cocoa.SWTDragSourceDelegate;
+import dwt.widgets.Control;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Listener;
+import dwt.widgets.Table;
+import dwt.widgets.Tree;
+import dwt.widgets.Widget;
/**
*
* DragSource
defines the source object for a drag and drop transfer.
@@ -95,24 +115,72 @@
* Styles DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
* Events DND.DragStart, DND.DragSetData, DND.DragEnd
*
+ *
+ * @see Drag and Drop snippets
+ * @see DWT Example: DNDExample
+ * @see Sample code and further information
*/
-public class DragSource : Widget {
+public class DragSource extends Widget {
+
+ static Callback dragSource2Args, dragSource3Args, dragSource4Args, dragSource5Args;
+ static final String DWT_OBJECT = "DWT_OBJECT";
+
+ static {
+ String className = "SWTDragSourceDelegate";
+
+ // TODO: These should either move out of Display or be accessible to this class.
+ String types = "*";
+ int size = C.PTR_SIZEOF, align = C.PTR_SIZEOF is 4 ? 2 : 3;
+
+ Class clazz = DragSource.class;
+
+ dragSource2Args = new Callback(clazz, "dragSourceProc", 2);
+ int /*long*/ proc2 = dragSource2Args.getAddress();
+ if (proc2 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+
+ dragSource3Args = new Callback(clazz, "dragSourceProc", 3);
+ int /*long*/ proc3 = dragSource3Args.getAddress();
+ if (proc3 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+
+ dragSource4Args = new Callback(clazz, "dragSourceProc", 4);
+ int /*long*/ proc4 = dragSource4Args.getAddress();
+ if (proc4 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+
+ dragSource5Args = new Callback(clazz, "dragSourceProc", 5);
+ int /*long*/ proc5 = dragSource5Args.getAddress();
+ if (proc5 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+
+ int /*long*/ cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+ OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types);
+
+ int /*long*/ draggedImage_endedAt_operationProc = OS.draggedImage_endedAt_operation_CALLBACK(proc5);
+
+ // Add the NSDraggingSource callbacks
+ OS.class_addMethod(cls, OS.sel_draggingSourceOperationMaskForLocal_, proc3, "@:c");
+ OS.class_addMethod(cls, OS.sel_draggedImage_beganAt_, proc4, "@:@{NSPoint=ff}");
+ OS.class_addMethod(cls, OS.sel_draggedImage_endedAt_operation_, draggedImage_endedAt_operationProc, "@:@{NSPoint=ff}I");
+ OS.class_addMethod(cls, OS.sel_ignoreModifierKeysWhileDragging, proc3, "@:");
+
+ // Add the NSPasteboard delegate callback
+ OS.class_addMethod(cls, OS.sel_pasteboard_provideDataForType_, proc4, "@:@@");
+
+ OS.objc_registerClassPair(cls);
+ }
+
// info for registering as a drag source
Control control;
Listener controlListener;
Transfer[] transferAgents = new Transfer[0];
DragSourceEffect dragEffect;
-
- static final String DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$
- static Callback DragSendDataProc;
+ private int dragOperations;
+ SWTDragSourceDelegate dragSourceDelegate;
- static {
- DragSendDataProc = new Callback(DragSource.class, "DragSendDataProc", 4); //$NON-NLS-1$
- int dragSendDataProcAddress = DragSendDataProc.getAddress();
- if (dragSendDataProcAddress is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
- }
+ static final String DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$
+ bool dragStarted = false;
+ private int /*long*/ delegateJniRef;
+
/**
* Creates a new DragSource
to handle dragging from the specified Control
.
* Creating an instance of a DragSource may cause system resources to be allocated depending on the platform.
@@ -142,7 +210,7 @@
* @see DND#DROP_MOVE
* @see DND#DROP_LINK
*/
-public this(Control control, int style) {
+public DragSource(Control control, int style) {
super (control, checkStyle(style));
this.control = control;
if (control.getData(DND.DRAG_SOURCE_KEY) !is null) {
@@ -174,33 +242,20 @@
});
Object effect = control.getData(DEFAULT_DRAG_SOURCE_EFFECT);
- if ( null !is cast(DragSourceEffect)effect ) {
- dragEffect = cast(DragSourceEffect) effect;
- } else if ( null !is cast(Tree)control ) {
- dragEffect = new TreeDragSourceEffect(cast(Tree) control);
- } else if ( null !is cast(Table)control ) {
- dragEffect = new TableDragSourceEffect(cast(Table) control);
+ if (effect instanceof DragSourceEffect) {
+ dragEffect = (DragSourceEffect) effect;
+ } else if (control instanceof Tree) {
+ dragEffect = new TreeDragSourceEffect((Tree) control);
+ } else if (control instanceof Table) {
+ dragEffect = new TableDragSourceEffect((Table) control);
}
-}
-
-static int checkStyle (int style) {
- if (style is DWT.NONE) return DND.DROP_MOVE;
- return style;
-}
-
-static int DragSendDataProc(int theType, int dragSendRefCon, int theItemRef, int theDrag) {
- DragSource source = FindDragSource(dragSendRefCon, theDrag);
- if (source is null) return OS.cantGetFlavorErr;
- return source.dragSendDataProc(theType, dragSendRefCon, theItemRef, theDrag);
-}
-
-static DragSource FindDragSource(int dragSendRefCon, int theDrag) {
- if (dragSendRefCon is 0) return null;
- Display display = Display.findDisplay(Thread.currentThread());
- if (display is null || display.isDisposed()) return null;
- Widget widget = display.findWidget(dragSendRefCon);
- if (widget is null) return null;
- return cast(DragSource)widget.getData(DND.DRAG_SOURCE_KEY);
+
+ // Create a delegate, but then stuff a pointer back to this object so callbacks will have
+ // access to this object's data.
+ dragSourceDelegate = (SWTDragSourceDelegate)new SWTDragSourceDelegate().alloc().init();
+ delegateJniRef = OS.NewGlobalRef(this);
+ if (delegateJniRef is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+ OS.object_setInstanceVariable(dragSourceDelegate.id, DWT_OBJECT, delegateJniRef);
}
/**
@@ -229,6 +284,7 @@
*
*
* @see DragSourceListener
+ * @see #getDragListeners
* @see #removeDragListener
* @see DragSourceEvent
*/
@@ -244,11 +300,16 @@
protected void checkSubclass () {
String name = getClass().getName ();
String validName = DragSource.class.getName();
- if (!validName.opEquals(name)) {
+ if (!validName.equals(name)) {
DND.error (DWT.ERROR_INVALID_SUBCLASS);
}
}
+static int checkStyle (int style) {
+ if (style is DWT.NONE) return DND.DROP_MOVE;
+ return style;
+}
+
void drag(Event dragEvent) {
DNDEvent event = new DNDEvent();
event.widget = this;
@@ -259,135 +320,173 @@
notifyListeners(DND.DragStart, event);
if (!event.doit || transferAgents is null || transferAgents.length is 0) return;
- int[] theDrag = new int[1];
- if (OS.NewDrag(theDrag) !is OS.noErr) {
- event = new DNDEvent();
- event.widget = this;
- event.time = cast(int)System.currentTimeMillis();
- event.doit = false;
- event.detail = DND.DROP_NONE;
- notifyListeners(DND.DragEnd, event);
- return;
- }
+ NSPasteboard dragBoard = NSPasteboard.pasteboardWithName(OS.NSDragPboard);
+ NSMutableArray nativeTypeArray = NSMutableArray.arrayWithCapacity(10);
- Point pt = new Point();
- OS.GetGlobalMouse (pt);
-
for (int i = 0; i < transferAgents.length; i++) {
Transfer transfer = transferAgents[i];
if (transfer !is null) {
- int[] types = transfer.getTypeIds();
- if ( null !is cast(FileTransfer)transfer ) {
- TransferData transferData = new TransferData();
- transferData.type = types[0];
- DNDEvent event2 = new DNDEvent();
- event2.widget = this;
- event2.time = cast(int)System.currentTimeMillis();
- event2.dataType = transferData;
- notifyListeners(DND.DragSetData, event2);
- if (event2.data !is null) {
- for (int j = 0; j < types.length; j++) {
- transferData.type = types[j];
- transfer.javaToNative(event2.data, transferData);
- if (transferData.result is OS.noErr) {
- for (int k = 0; k < transferData.data.length; k++) {
- byte[] datum = transferData.data[k];
- OS.AddDragItemFlavor(theDrag[0], 1 + k, types[j], datum, datum.length, 0);
- }
- }
- }
- }
- } else {
- for (int j = 0; j < types.length; j++) {
- OS.AddDragItemFlavor(theDrag[0], 1, types[j], null, 0, 0);
- }
- }
- }
+ String[] typeNames = transfer.getTypeNames();
+
+ for (int j = 0; j < typeNames.length; j++) {
+ nativeTypeArray.addObject(NSString.stringWith(typeNames[j]));
+ }
+ }
}
+
+ if (nativeTypeArray !is null)
+ dragBoard.declareTypes(nativeTypeArray, dragSourceDelegate);
+
+ // Start the drag here from the Control's view.
+ NSEvent currEvent = NSApplication.sharedApplication().currentEvent();
+ NSPoint pt = currEvent.locationInWindow();
+ NSPoint viewPt = control.view.convertPoint_fromView_(pt, null);
+
+ // Save off the drag operations -- AppKit will call back to us to request them during the drag.
+ dragOperations = opToOsOp(getStyle());
- OS.SetDragSendProc(theDrag[0], DragSendDataProc.getAddress(), control.handle);
-
- int theRegion = 0;
+ // Get the image for the drag. The drag should happen from the middle of the image.
+ NSImage dragImage = null;
Image newImage = null;
try {
- theRegion = OS.NewRgn();
- OS.SetRectRgn(theRegion, cast(short)(pt.h), cast(short)(pt.v), cast(short)(pt.h+20), cast(short)(pt.v+20));
+ Image image = event.image;
- int operations = opToOsOp(getStyle());
- //set operations twice - local and not local
- OS.SetDragAllowableActions(theDrag[0], operations, true);
- OS.SetDragAllowableActions(theDrag[0], operations, false);
+ // If no image was provided, just create a trivial image. dragImage requires a non-null image.
+ if (image is null) {
+ newImage = new Image(Display.getCurrent(), 1, 1);
+ image = newImage;
+ }
+
+ dragImage = image.handle;
+
+ NSSize imageSize = dragImage.size();
+ viewPt.x -= (imageSize.width / 2);
+ viewPt.y -= (imageSize.height / 2);
- Image image = event.image;
- if (image !is null) {
- CGPoint imageOffsetPt = new CGPoint();
- imageOffsetPt.x = 0;
- imageOffsetPt.y = 0;
- /*
- * Bug in the Macintosh. For some reason, it seems that SetDragImageWithCGImage()
- * expects an image with the alpha, otherwise the image does not draw. The fix is
- * to make sure that the image has an alpha by creating a new image with alpha
- * when necessary.
- */
- if (OS.CGImageGetAlphaInfo(image.handle) is OS.kCGImageAlphaNoneSkipFirst) {
- ImageData data = image.getImageData();
- data.alpha = 0xFF;
- newImage = new Image(image.getDevice(), data);
- image = newImage;
- }
- OS.SetDragImageWithCGImage(theDrag[0], image.handle, imageOffsetPt, 0);
+ // The third argument to dragImage is ignored as of 10.4.
+ NSSize ignored = new NSSize();
+ ignored.width = 0;
+ ignored.height = 0;
+
+ dragStarted = false;
+ control.view.dragImage(dragImage, viewPt, ignored, NSApplication.sharedApplication().currentEvent(), dragBoard, dragSourceDelegate, true);
+
+ // If we actually dragged, dragStarted will be set to true in dragImage:beganAt:
+ // If not, send a DragEnd indicating nothing happened.
+ if (!dragStarted) {
+ event = new DNDEvent();
+ event.widget = this;
+ event.time = (int)System.currentTimeMillis();
+ event.doit = false;
+ event.detail = DND.DROP_NONE;
+ notifyListeners(DND.DragEnd, event);
}
- EventRecord theEvent = new EventRecord();
- theEvent.message = OS.kEventMouseMoved;
- theEvent.modifiers = cast(short)OS.GetCurrentEventKeyModifiers();
- theEvent.what = cast(short)OS.osEvt;
- theEvent.where_h = pt.h;
- theEvent.where_v = pt.v;
- int result = OS.TrackDrag(theDrag[0], theEvent, theRegion);
- int operation = DND.DROP_NONE;
- if (result is OS.noErr) {
- int[] outAction = new int[1];
- OS.GetDragDropAction(theDrag[0], outAction);
- operation = osOpToOp(outAction[0]);
- }
- event = new DNDEvent();
- event.widget = this;
- event.time = cast(int)System.currentTimeMillis();
- event.doit = result is OS.noErr;
- event.detail = operation;
- notifyListeners(DND.DragEnd, event);
} finally {
- if (theRegion !is 0) OS.DisposeRgn(theRegion);
if (newImage !is null) newImage.dispose();
}
- OS.DisposeDrag(theDrag[0]);
+}
+
+void draggedImage_beganAt(NSImage image) {
+ this.dragStarted = true;
+}
+
+void draggedImage_endedAt_operation(NSImage image, NSPoint location, int /*long*/ operation) {
+ int swtOperation = osOpToOp(operation);
+ Event event = new DNDEvent();
+ event.widget = this;
+ event.time = (int)System.currentTimeMillis();
+ event.doit = swtOperation !is DND.DROP_NONE;
+ event.detail = swtOperation;
+ notifyListeners(DND.DragEnd, event);
+}
+
+/**
+ * Cocoa NSDraggingSource implementations
+ */
+int draggingSourceOperationMaskForLocal(bool flag) {
+ // Drag operations are same for local or remote drags.
+ return dragOperations;
+}
+
+static int /*long*/ dragSourceProc(int /*long*/ id, int /*long*/ sel) {
+ Display display = Display.findDisplay(Thread.currentThread());
+ if (display is null || display.isDisposed()) return 0;
+ Widget widget = display.findWidget(id);
+ if (widget is null) return 0;
+ DragSource ds = (DragSource)widget.getData(DND.DRAG_SOURCE_KEY);
+ if (ds is null) return 0;
+
+ if (sel is OS.sel_ignoreModifierKeysWhileDragging) {
+ return (ds.ignoreModifierKeysWhileDragging() ? 1 : 0);
+ }
+
+ return 0;
}
-int dragSendDataProc(int theType, int dragSendRefCon, int theItemRef, int theDrag) {
- if (theType is 0) return OS.badDragFlavorErr;
- TransferData transferData = new TransferData();
- transferData.type = theType;
- DNDEvent event = new DNDEvent();
- event.widget = this;
- event.time = cast(int)System.currentTimeMillis();
- event.dataType = transferData;
- notifyListeners(DND.DragSetData, event);
- Transfer transfer = null;
- for (int i = 0; i < transferAgents.length; i++) {
- Transfer transferAgent = transferAgents[i];
- if (transferAgent !is null && transferAgent.isSupportedType(transferData)) {
- transfer = transferAgent;
- break;
- }
+static int /*long*/ dragSourceProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) {
+ Display display = Display.findDisplay(Thread.currentThread());
+ if (display is null || display.isDisposed()) return 0;
+ Widget widget = display.findWidget(id);
+ if (widget is null) return 0;
+ DragSource ds = null;
+
+ if (widget instanceof DragSource)
+ ds = (DragSource)widget;
+
+ if (ds is null) return 0;
+
+ if (sel is OS.sel_draggingSourceOperationMaskForLocal_) {
+ return ds.draggingSourceOperationMaskForLocal(arg0 is 1);
}
- if (transfer is null) return OS.badDragFlavorErr;
- transfer.javaToNative(event.data, transferData);
- if (transferData.result !is OS.noErr) return transferData.result;
- // Except for FileTransfer (see #drag), only one item can be transferred
- // in a Drag operation
- byte[] datum = transferData.data[0];
- if (datum is null) return OS.cantGetFlavorErr;
- return OS.SetDragItemFlavorData(theDrag, theItemRef, theType, datum, datum.length, 0);
+
+ return 0;
+}
+
+static int /*long*/ dragSourceProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int /*long*/ arg1) {
+ Display display = Display.findDisplay(Thread.currentThread());
+ if (display is null || display.isDisposed()) return 0;
+ Widget widget = display.findWidget(id);
+ if (widget is null) return 0;
+ DragSource ds = null;
+
+ if (widget instanceof DragSource)
+ ds = (DragSource)widget;
+
+ if (ds is null) return 0;
+
+ if (sel is OS.sel_draggedImage_beganAt_) {
+ NSImage image = new NSImage(arg0);
+ // I am deliberately ignoring arg1 (an NSPoint). It's not needed for our purposes.
+ ds.draggedImage_beganAt(image);
+ } else if (sel is OS.sel_pasteboard_provideDataForType_) {
+ NSPasteboard pb = new NSPasteboard(arg0);
+ NSString type = new NSString(arg1);
+ ds.pasteboard_provideDataForType(pb, type);
+ }
+
+ return 0;
+}
+
+static int /*long*/ dragSourceProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2) {
+ Display display = Display.findDisplay(Thread.currentThread());
+ if (display is null || display.isDisposed()) return 0;
+ Widget widget = display.findWidget(id);
+ if (widget is null) return 0;
+ DragSource ds = null;
+
+ if (widget instanceof DragSource)
+ ds = (DragSource)widget;
+
+ if (ds is null) return 0;
+
+ if (sel is OS.sel_draggedImage_endedAt_operation_) {
+ NSImage image = new NSImage(arg0);
+ NSPoint point = new NSPoint();
+ OS.memmove(point, arg1, NSPoint.sizeof);
+ ds.draggedImage_endedAt_operation(image, point, arg2);
+ }
+
+ return 0;
}
/**
@@ -405,6 +504,9 @@
* operation is in progress, by sending it one of the messages defined in
* the DragSourceListener
interface.
*
+ * @return the listeners who will be notified when a drag and drop
+ * operation is in progress
+ *
* @exception DWTException
* - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
* - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
@@ -424,8 +526,8 @@
int count = 0;
for (int i = 0; i < length; i++) {
Listener listener = listeners[i];
- if ( null !is cast(DNDListener)listener ) {
- dragListeners[count] = cast(DragSourceListener) (cast(DNDListener) listener).getEventListener();
+ if (listener instanceof DNDListener) {
+ dragListeners[count] = (DragSourceListener) ((DNDListener) listener).getEventListener();
count++;
}
}
@@ -456,6 +558,13 @@
return transferAgents;
}
+/**
+ * We always want the modifier keys to potentially update the drag.
+ */
+bool ignoreModifierKeysWhileDragging() {
+ return false;
+}
+
void onDispose() {
if (control is null)
return;
@@ -467,50 +576,90 @@
control.setData(DND.DRAG_SOURCE_KEY, null);
control = null;
transferAgents = null;
+
+ if (delegateJniRef !is 0) OS.DeleteGlobalRef(delegateJniRef);
+ if (dragSourceDelegate !is null) dragSourceDelegate.release();
}
int opToOsOp(int operation) {
int osOperation = 0;
if ((operation & DND.DROP_COPY) !is 0){
- osOperation |= OS.kDragActionCopy;
+ osOperation |= OS.NSDragOperationCopy;
}
if ((operation & DND.DROP_LINK) !is 0) {
- osOperation |= OS.kDragActionAlias;
+ osOperation |= OS.NSDragOperationLink;
}
if ((operation & DND.DROP_MOVE) !is 0) {
- osOperation |= OS.kDragActionMove;
+ osOperation |= OS.NSDragOperationMove;
}
if ((operation & DND.DROP_TARGET_MOVE) !is 0) {
- osOperation |= OS.kDragActionDelete;
+ osOperation |= OS.NSDragOperationDelete;
}
return osOperation;
}
-int osOpToOp(int osOperation){
+int osOpToOp(int /*long*/ osOperation){
int operation = 0;
- if ((osOperation & OS.kDragActionCopy) !is 0){
+ if ((osOperation & OS.NSDragOperationCopy) !is 0){
operation |= DND.DROP_COPY;
}
- if ((osOperation & OS.kDragActionAlias) !is 0) {
+ if ((osOperation & OS.NSDragOperationLink) !is 0) {
operation |= DND.DROP_LINK;
}
- if ((osOperation & OS.kDragActionDelete) !is 0) {
+ if ((osOperation & OS.NSDragOperationDelete) !is 0) {
operation |= DND.DROP_TARGET_MOVE;
}
- if ((osOperation & OS.kDragActionMove) !is 0) {
+ if ((osOperation & OS.NSDragOperationMove) !is 0) {
operation |= DND.DROP_MOVE;
}
- if (osOperation is OS.kDragActionAll) {
+ if (osOperation is OS.NSDragOperationEvery) {
operation = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
}
return operation;
}
+void pasteboard_provideDataForType(NSPasteboard pasteboard, NSString dataType) {
+ if (pasteboard is null || dataType is null) return;
+ TransferData transferData = new TransferData();
+ transferData.type = Transfer.registerType(dataType.getString());
+ DNDEvent event = new DNDEvent();
+ event.widget = this;
+ event.time = (int)System.currentTimeMillis();
+ event.dataType = transferData;
+ notifyListeners(DND.DragSetData, event);
+ Transfer transfer = null;
+ for (int i = 0; i < transferAgents.length; i++) {
+ Transfer transferAgent = transferAgents[i];
+ if (transferAgent !is null && transferAgent.isSupportedType(transferData)) {
+ transfer = transferAgent;
+ break;
+ }
+ }
+ if (transfer is null) return;
+ transfer.javaToNative(event.data, transferData);
+ if (transferData.data is null) return;
+
+ NSObject tdata = transferData.data;
+
+ if (dataType.isEqual(OS.NSStringPboardType) ||
+ dataType.isEqual(OS.NSHTMLPboardType) ||
+ dataType.isEqual(OS.NSRTFPboardType)) {
+ pasteboard.setString((NSString) tdata, dataType);
+ } else if (dataType.isEqual(OS.NSURLPboardType)) {
+ NSURL url = (NSURL) tdata;
+ url.writeToPasteboard(pasteboard);
+ } else if (dataType.isEqual(OS.NSFilenamesPboardType)) {
+ pasteboard.setPropertyList((NSArray) tdata, dataType);
+ } else {
+ pasteboard.setData((NSData) tdata, dataType);
+ }
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when a drag and drop operation is in progress.
*
- * @param listener the listener which should be notified
+ * @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException
* - ERROR_NULL_ARGUMENT - if the listener is null
@@ -522,6 +671,7 @@
*
* @see DragSourceListener
* @see #addDragListener
+ * @see #getDragListeners
*/
public void removeDragListener(DragSourceListener listener) {
if (listener is null) DND.error (DWT.ERROR_NULL_ARGUMENT);
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DragSourceAdapter.d
--- a/dwt/dnd/DragSourceAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DragSourceAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2004 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
@@ -8,7 +8,9 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DragSourceAdapter;
+
+import dwt.dwthelper.utils;
/**
@@ -21,21 +23,32 @@
*
* @see DragSourceListener
* @see DragSourceEvent
+ * @see Sample code and further information
*/
-public class DragSourceAdapter : DragSourceListener {
- /**
- * This implementation of dragStart
permits the drag operation to start.
- * For additional information see DragSourceListener.dragStart
.
- */
- public void dragStart(DragSourceEvent event){}
- /**
- * This implementation of dragFinished
does nothing.
- * For additional information see DragSourceListener.dragFinished
.
- */
- public void dragFinished(DragSourceEvent event){}
- /**
- * This implementation of dragSetData
does nothing.
- * For additional information see DragSourceListener.dragSetData
.
- */
- public void dragSetData(DragSourceEvent event){}
+public class DragSourceAdapter implements DragSourceListener {
+
+/**
+ * This implementation of dragStart
permits the drag operation to start.
+ * For additional information see DragSourceListener.dragStart
.
+ *
+ * @param event the information associated with the drag start event
+ */
+public void dragStart(DragSourceEvent event){}
+
+/**
+ * This implementation of dragFinished
does nothing.
+ * For additional information see DragSourceListener.dragFinished
.
+ *
+ * @param event the information associated with the drag finished event
+ */
+public void dragFinished(DragSourceEvent event){}
+
+/**
+ * This implementation of dragSetData
does nothing.
+ * For additional information see DragSourceListener.dragSetData
.
+ *
+ * @param event the information associated with the drag set data event
+ */
+public void dragSetData(DragSourceEvent event){}
+
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DragSourceEffect.d
--- a/dwt/dnd/DragSourceEffect.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DragSourceEffect.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 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
@@ -8,10 +8,12 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DragSourceEffect;
-import dwt.*;
-import dwt.widgets.*;
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.widgets.Control;
/**
* This class provides default implementations to display a drag source
@@ -32,10 +34,11 @@
*
* @see DragSourceAdapter
* @see DragSourceEvent
+ * @see Sample code and further information
*
* @since 3.3
*/
-public class DragSourceEffect : DragSourceAdapter {
+public class DragSourceEffect extends DragSourceAdapter {
Control control = null;
/**
@@ -47,7 +50,7 @@
* - ERROR_NULL_ARGUMENT - if the control is null
*
*/
- public this(Control control) {
+ public DragSourceEffect(Control control) {
if (control is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
this.control = control;
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DragSourceEvent.d
--- a/dwt/dnd/DragSourceEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DragSourceEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -8,17 +8,20 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DragSourceEvent;
+
+import dwt.dwthelper.utils;
import dwt.events.TypedEvent;
-import dwt.graphics.*;
+import dwt.graphics.Image;
/**
* The DragSourceEvent contains the event information passed in the methods of the DragSourceListener.
*
* @see DragSourceListener
+ * @see Sample code and further information
*/
-public class DragSourceEvent : TypedEvent {
+public class DragSourceEvent extends TypedEvent {
/**
* The operation that was performed.
* @see DND#DROP_NONE
@@ -48,12 +51,14 @@
/**
* In dragStart, the x coordinate (relative to the control) of the
* position the mouse went down to start the drag.
+ *
* @since 3.2
*/
public int x;
/**
* In dragStart, the y coordinate (relative to the control) of the
- * position the mouse went down to start the drag .
+ * position the mouse went down to start the drag.
+ *
* @since 3.2
*/
public int y;
@@ -73,6 +78,19 @@
*/
public Image image;
+ /**
+ * In dragStart, the x offset (relative to the image) where the drag source image will be displayed.
+ *
+ * @since 3.5
+ */
+ public int offsetX;
+ /**
+ * In dragStart, the y offset (relative to the image) where the drag source image will be displayed.
+ *
+ * @since 3.5
+ */
+ public int offsetY;
+
static final long serialVersionUID = 3257002142513770808L;
/**
@@ -81,7 +99,7 @@
*
* @param e the untyped event containing the information
*/
-public this(DNDEvent e) {
+public DragSourceEvent(DNDEvent e) {
super(e);
this.data = e.data;
this.detail = e.detail;
@@ -90,6 +108,8 @@
this.x = e.x;
this.y = e.y;
this.image = e.image;
+ this.offsetX = e.offsetX;
+ this.offsetY = e.offsetY;
}
void updateEvent(DNDEvent e) {
e.widget = this.widget;
@@ -101,5 +121,21 @@
e.x = this.x;
e.y = this.y;
e.image = this.image;
+ e.offsetX = this.offsetX;
+ e.offsetY = this.offsetY;
+}
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+ String string = super.toString ();
+ return string.substring (0, string.length() - 1) // remove trailing '}'
+ + " operation=" + detail
+ + " type=" + (dataType !is null ? dataType.type : 0)
+ + " doit=" + doit
+ + "}";
}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DragSourceListener.d
--- a/dwt/dnd/DragSourceListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DragSourceListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -8,7 +8,9 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DragSourceListener;
+
+import dwt.dwthelper.utils;
import dwt.internal.DWTEventListener;
@@ -24,7 +26,7 @@
* move operation, the application must remove the data that was transferred.
*
*/
-public interface DragSourceListener : DWTEventListener {
+public interface DragSourceListener extends DWTEventListener {
/**
* The user has begun the actions required to drag the widget. This event gives the application
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DropTarget.d
--- a/dwt/dnd/DropTarget.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DropTarget.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -8,13 +8,37 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DropTarget;
+import dwt.dwthelper.utils;
+
+import java.util.ArrayList;
-import dwt.*;
-import dwt.widgets.*;
-import dwt.internal.*;
-import dwt.internal.carbon.*;
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.internal.Callback;
+import dwt.internal.cocoa.NSApplication;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSCursor;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSMutableArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPasteboard;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSScreen;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.id;
+import dwt.widgets.Control;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Listener;
+import dwt.widgets.Table;
+import dwt.widgets.Tree;
+import dwt.widgets.Widget;
/**
*
@@ -56,7 +80,7 @@
* event.detail = DND.DROP_NONE;
* return;
* }
- * label.setText (cast(String) event.data); // data copied to label text
+ * label.setText ((String) event.data); // data copied to label text
* }
* });
*
@@ -66,8 +90,27 @@
* - Events
- DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged,
* DND.DropAccept, DND.Drop
*
+ *
+ * @see Drag and Drop snippets
+ * @see DWT Example: DNDExample
+ * @see Sample code and further information
*/
-public class DropTarget : Widget {
+public class DropTarget extends Widget {
+
+ static Callback dropTarget2Args, dropTarget3Args;
+ static int /*long*/ proc2Args, proc3Args;
+
+ static {
+ Class clazz = DropTarget.class;
+
+ dropTarget2Args = new Callback(clazz, "dropTargetProc", 2);
+ proc2Args = dropTarget2Args.getAddress();
+ if (proc2Args is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+
+ dropTarget3Args = new Callback(clazz, "dropTargetProc", 3);
+ proc3Args = dropTarget3Args.getAddress();
+ if (proc3Args is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+ }
Control control;
Listener controlListener;
@@ -82,33 +125,199 @@
// workaround - There is no event for "operation changed" so track operation based on key state
int keyOperation = -1;
- // workaround - Simulate events when mouse is not moving
- long dragOverStart;
- Runnable dragOverHeartbeat;
- DNDEvent dragOverEvent;
+ static final String DEFAULT_DROP_TARGET_EFFECT = "DEFAULT_DROP_TARGET_EFFECT"; //$NON-NLS-1$
- // workaround - OS events are relative to the application, not the control.
- // Track which control is the current target to determine when drag and
- // drop enters or leaves a widget.
- static DropTarget CurrentDropTarget = null;
+void addDragHandlers() {
+ // Our strategy here is to dynamically add methods to the control's class that are required
+ // by NSDraggingDestination. Then, when setTransfer is called, we just register
+ // the types with the Control's NSView and AppKit will call the methods in the protocol
+ // when a drag goes over the view.
+
+ int /*long*/ cls = OS.object_getClass(control.view.id);
+
+ if (cls is 0) {
+ DND.error(DND.ERROR_CANNOT_INIT_DROP);
+ }
+
+ // If we already added it, no need to do it again.
+ int /*long*/ procPtr = OS.class_getMethodImplementation(cls, OS.sel_draggingEnded_);
+ if (procPtr is proc3Args) return;
+
+ // Add the NSDraggingDestination callbacks
+ OS.class_addMethod(cls, OS.sel_draggingEntered_, proc3Args, "@:@");
+ OS.class_addMethod(cls, OS.sel_draggingUpdated_, proc3Args, "@:@");
+ OS.class_addMethod(cls, OS.sel_draggingExited_, proc3Args, "@:@");
+ OS.class_addMethod(cls, OS.sel_performDragOperation_, proc3Args, "@:@");
+ OS.class_addMethod(cls, OS.sel_wantsPeriodicDraggingUpdates, proc2Args, "@:");
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the DropTargetListener
+ * interface.
+ *
+ *
+ * dragEnter
is called when the cursor has entered the drop target boundaries
+ * dragLeave
is called when the cursor has left the drop target boundaries and just before
+ * the drop occurs or is cancelled.
+ * dragOperationChanged
is called when the operation being performed has changed
+ * (usually due to the user changing the selected modifier key(s) while dragging)
+ * dragOver
is called when the cursor is moving over the drop target
+ * dropAccept
is called just before the drop is performed. The drop target is given
+ * the chance to change the nature of the drop or veto the drop by setting the event.detail
field
+ * drop
is called when the data is being dropped
+ *
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception DWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ *
+ * @see DropTargetListener
+ * @see #getDropListeners
+ * @see #removeDropListener
+ * @see DropTargetEvent
+ */
+public void addDropListener(DropTargetListener listener) {
+ if (listener is null) DND.error (DWT.ERROR_NULL_ARGUMENT);
+ DNDListener typedListener = new DNDListener (listener);
+ typedListener.dndWidget = this;
+ addListener (DND.DragEnter, typedListener);
+ addListener (DND.DragLeave, typedListener);
+ addListener (DND.DragOver, typedListener);
+ addListener (DND.DragOperationChanged, typedListener);
+ addListener (DND.Drop, typedListener);
+ addListener (DND.DropAccept, typedListener);
+}
+
+static int checkStyle (int style) {
+ if (style is DWT.NONE) return DND.DROP_MOVE;
+ return style;
+}
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DropTarget.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (DWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+
+int draggingEntered(NSObject sender) {
+ selectedDataType = null;
+ selectedOperation = 0;
- static final String DEFAULT_DROP_TARGET_EFFECT = "DEFAULT_DROP_TARGET_EFFECT"; //$NON-NLS-1$
- static final int DRAGOVER_HYSTERESIS = 50;
+ DNDEvent event = new DNDEvent();
+ if (!setEventData(sender, event)) {
+ keyOperation = -1;
+ if (OS.PTR_SIZEOF is 4) OS.SetThemeCursor(OS.kThemeNotAllowedCursor);
+ return OS.NSDragOperationNone;
+ }
- static Callback DragTrackingHandler;
- static Callback DragReceiveHandler;
+ int allowedOperations = event.operations;
+ TransferData[] allowedDataTypes = new TransferData[event.dataTypes.length];
+ System.arraycopy(event.dataTypes, 0, allowedDataTypes, 0, allowedDataTypes.length);
+
+ notifyListeners(DND.DragEnter, event);
+
+ if (event.detail is DND.DROP_DEFAULT) {
+ event.detail = (allowedOperations & DND.DROP_MOVE) !is 0 ? DND.DROP_MOVE : DND.DROP_NONE;
+ }
+
+ selectedDataType = null;
+ for (int i = 0; i < allowedDataTypes.length; i++) {
+ if (allowedDataTypes[i].type is event.dataType.type) {
+ selectedDataType = allowedDataTypes[i];
+ break;
+ }
+ }
+
+ selectedOperation = DND.DROP_NONE;
+ if (selectedDataType !is null && (allowedOperations & event.detail) !is 0) {
+ selectedOperation = event.detail;
+ }
+
+ int osOperation = opToOsOp(selectedOperation);
+
+ if (OS.PTR_SIZEOF is 4) {
+ switch (selectedOperation) {
+ case DND.DROP_COPY:
+ OS.SetThemeCursor(OS.kThemeCopyArrowCursor);
+ break;
+ case DND.DROP_LINK:
+ OS.SetThemeCursor(OS.kThemeAliasArrowCursor);
+ break;
+ case DND.DROP_MOVE:
+ NSCursor.arrowCursor().set();
+ break;
+ default:
+ OS.SetThemeCursor(OS.kThemeNotAllowedCursor);
+ }
+ }
+ return osOperation;
+}
+
+void draggingExited(NSObject sender) {
+ NSCursor.arrowCursor().set();
+ if (keyOperation is -1) return;
+ keyOperation = -1;
- static {
- DragTrackingHandler = new Callback(DropTarget.class, "DragTrackingHandler", 4); //$NON-NLS-1$
- int dragTrackingHandlerAddress = DragTrackingHandler.getAddress();
- if (dragTrackingHandlerAddress is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
- DragReceiveHandler = new Callback(DropTarget.class, "DragReceiveHandler", 3); //$NON-NLS-1$
- int dragReceiveHandlerAddress = DragReceiveHandler.getAddress();
- if (dragReceiveHandlerAddress is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
- OS.InstallTrackingHandler(dragTrackingHandlerAddress, 0, null);
- OS.InstallReceiveHandler(dragReceiveHandlerAddress, 0, null);
+ DNDEvent event = new DNDEvent();
+ event.widget = this;
+ event.time = (int)System.currentTimeMillis();
+ event.detail = DND.DROP_NONE;
+ notifyListeners(DND.DragLeave, event);
+}
+
+int draggingUpdated(NSObject sender) {
+ if (sender is null) return OS.NSDragOperationNone;
+ int oldKeyOperation = keyOperation;
+
+ DNDEvent event = new DNDEvent();
+ if (!setEventData(sender, event)) {
+ keyOperation = -1;
+ if (OS.PTR_SIZEOF is 4) OS.SetThemeCursor(OS.kThemeNotAllowedCursor);
+ return OS.NSDragOperationNone;
}
+ int allowedOperations = event.operations;
+ TransferData[] allowedDataTypes = new TransferData[event.dataTypes.length];
+ System.arraycopy(event.dataTypes, 0, allowedDataTypes, 0, allowedDataTypes.length);
+
+ if (keyOperation is oldKeyOperation) {
+ event.type = DND.DragOver;
+ event.dataType = selectedDataType;
+ event.detail = selectedOperation;
+ } else {
+ event.type = DND.DragOperationChanged;
+ event.dataType = selectedDataType;
+ }
+ notifyListeners(event.type, event);
+ if (event.detail is DND.DROP_DEFAULT) {
+ event.detail = (allowedOperations & DND.DROP_MOVE) !is 0 ? DND.DROP_MOVE : DND.DROP_NONE;
+ }
+
+ selectedDataType = null;
+ for (int i = 0; i < allowedDataTypes.length; i++) {
+ if (allowedDataTypes[i].type is event.dataType.type) {
+ selectedDataType = allowedDataTypes[i];
+ break;
+ }
+ }
+
+ selectedOperation = DND.DROP_NONE;
+ if (selectedDataType !is null && ((allowedOperations & event.detail) is event.detail)) {
+ selectedOperation = event.detail;
+ }
+ return opToOsOp(selectedOperation);
+}
+
/**
* Creates a new DropTarget
to allow data to be dropped on the specified
* Control
.
@@ -140,15 +349,14 @@
* @see DND#DROP_MOVE
* @see DND#DROP_LINK
*/
-public this(Control control, int style) {
+public DropTarget(Control control, int style) {
super(control, checkStyle(style));
this.control = control;
- if (DragTrackingHandler is null || DragTrackingHandler is null) {
- DND.error(DND.ERROR_CANNOT_INIT_DROP);
- }
+
if (control.getData(DND.DROP_TARGET_KEY) !is null) {
DND.error(DND.ERROR_CANNOT_INIT_DROP);
}
+
control.setData(DND.DROP_TARGET_KEY, this);
controlListener = new Listener () {
@@ -167,179 +375,214 @@
});
Object effect = control.getData(DEFAULT_DROP_TARGET_EFFECT);
- if ( null !is cast(DropTargetEffect)effect ) {
- dropEffect = cast(DropTargetEffect) effect;
- } else if ( null !is cast(Table)control ) {
- dropEffect = new TableDropTargetEffect(cast(Table) control);
- } else if ( null !is cast(Tree)control ) {
- dropEffect = new TreeDropTargetEffect(cast(Tree) control);
+ if (effect instanceof DropTargetEffect) {
+ dropEffect = (DropTargetEffect) effect;
+ } else if (control instanceof Table) {
+ dropEffect = new TableDropTargetEffect((Table) control);
+ } else if (control instanceof Tree) {
+ dropEffect = new TreeDropTargetEffect((Tree) control);
}
- dragOverHeartbeat = new Runnable() {
- public void run() {
- Control control = DropTarget.this.control;
- if (control is null || control.isDisposed() || dragOverStart is 0) return;
- long time = System.currentTimeMillis();
- int delay = DRAGOVER_HYSTERESIS;
- if (time < dragOverStart) {
- delay = cast(int)(dragOverStart - time);
- } else {
- int allowedOperations = dragOverEvent.operations;
- TransferData[] allowedTypes = dragOverEvent.dataTypes;
- //pass a copy of data types in to listeners in case application modifies it
- TransferData[] dataTypes = new TransferData[allowedTypes.length];
- System.arraycopy(allowedTypes, 0, dataTypes, 0, dataTypes.length);
-
- DNDEvent event = new DNDEvent();
- event.widget = dragOverEvent.widget;
- event.x = dragOverEvent.x;
- event.y = dragOverEvent.y;
- event.time = cast(int)time;
- event.feedback = DND.FEEDBACK_SELECT;
- event.dataTypes = dataTypes;
- event.dataType = selectedDataType;
- event.operations = dragOverEvent.operations;
- event.detail = selectedOperation;
- if (dropEffect !is null) {
- event.item = dropEffect.getItem(event.x, event.y);
- }
- selectedDataType = null;
- selectedOperation = DND.DROP_NONE;
- notifyListeners(DND.DragOver, event);
- if (event.dataType !is null) {
- for (int i = 0; i < allowedTypes.length; i++) {
- if (allowedTypes[i].type is event.dataType.type) {
- selectedDataType = event.dataType;
- break;
- }
- }
- }
- if (selectedDataType !is null && (event.detail & allowedOperations) !is 0) {
- selectedOperation = event.detail;
- }
- }
- control = DropTarget.this.control;
- if (control is null || control.isDisposed()) return;
- control.getDisplay().timerExec(delay, dragOverHeartbeat);
- }
- };
+ addDragHandlers();
}
-static int checkStyle (int style) {
- if (style is DWT.NONE) return DND.DROP_MOVE;
- return style;
+static int /*long*/ dropTargetProc(int /*long*/ id, int /*long*/ sel) {
+ Display display = Display.findDisplay(Thread.currentThread());
+ if (display is null || display.isDisposed()) return 0;
+ Widget widget = display.findWidget(id);
+ if (widget is null) return 0;
+ DropTarget dt = (DropTarget)widget.getData(DND.DROP_TARGET_KEY);
+ if (dt is null) return 0;
+
+ if (sel is OS.sel_wantsPeriodicDraggingUpdates) {
+ return dt.wantsPeriodicDraggingUpdates() ? 1 : 0;
+ }
+
+ return 0;
}
-static int DragReceiveHandler(int theWindow, int handlerRefCon, int theDrag) {
- DropTarget target = FindDropTarget(theWindow, theDrag);
- if (target is null) return OS.noErr;
- return target.dragReceiveHandler(theWindow, handlerRefCon, theDrag);
-}
-
-static int DragTrackingHandler(int message, int theWindow, int handlerRefCon, int theDrag) {
- if (message is OS.kDragTrackingLeaveHandler || message is OS.kDragTrackingEnterHandler) {
- CurrentDropTarget = null;
- return OS.noErr;
+static int /*long*/ dropTargetProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) {
+ Display display = Display.findDisplay(Thread.currentThread());
+ if (display is null || display.isDisposed()) return 0;
+ Widget widget = display.findWidget(id);
+ if (widget is null) return 0;
+ DropTarget dt = (DropTarget)widget.getData(DND.DROP_TARGET_KEY);
+ if (dt is null) return 0;
+
+ // arg0 is _always_ the sender, and implements NSDraggingInfo.
+ // Looks like an NSObject for our purposes, though.
+ NSObject sender = new NSObject(arg0);
+
+ if (sel is OS.sel_draggingEntered_) {
+ return dt.draggingEntered(sender);
+ } else if (sel is OS.sel_draggingUpdated_) {
+ return dt.draggingUpdated(sender);
+ } else if (sel is OS.sel_draggingExited_) {
+ dt.draggingExited(sender);
+ } else if (sel is OS.sel_performDragOperation_) {
+ return dt.performDragOperation(sender) ? 1 : 0;
}
- DropTarget target = FindDropTarget(theWindow, theDrag);
- if (CurrentDropTarget !is null) {
- if (target is null || CurrentDropTarget.control.handle !is target.control.handle) {
- CurrentDropTarget.dragTrackingHandler(OS.kDragTrackingLeaveWindow, theWindow, handlerRefCon, theDrag);
- CurrentDropTarget = target;
- message = OS.kDragTrackingEnterWindow;
- }
- } else {
- CurrentDropTarget = target;
- message = OS.kDragTrackingEnterWindow;
- }
- if (target is null) return OS.noErr;
- return target.dragTrackingHandler(message, theWindow, handlerRefCon, theDrag);
+
+ return 0;
}
-static DropTarget FindDropTarget(int theWindow, int theDrag) {
- Display display = Display.findDisplay(Thread.currentThread());
- if (display is null || display.isDisposed()) return null;
- Point mouse = new Point();
- OS.GetDragMouse(theDrag, mouse, null);
- int[] theRoot = new int[1];
- OS.GetRootControl(theWindow, theRoot);
- int[] theControl = new int[1];
- Rect rect = new Rect();
- OS.GetWindowBounds (theWindow, cast(short) OS.kWindowContentRgn, rect);
- CGPoint inPoint = new CGPoint();
- inPoint.x = mouse.h - rect.left;
- inPoint.y = mouse.v - rect.top;
- OS.HIViewGetSubviewHit(theRoot[0], inPoint, true, theControl);
- if (!OS.IsControlEnabled(theControl[0])) return null;
- Widget widget = display.findWidget(theControl[0]);
- if (widget is null) return null;
- return cast(DropTarget)widget.getData(DND.DROP_TARGET_KEY);
-}
/**
- * Adds the listener to the collection of listeners who will
- * be notified when a drag and drop operation is in progress, by sending
- * it one of the messages defined in the DropTargetListener
- * interface.
- *
- *
- * dragEnter
is called when the cursor has entered the drop target boundaries
- * dragLeave
is called when the cursor has left the drop target boundaries and just before
- * the drop occurs or is cancelled.
- * dragOperationChanged
is called when the operation being performed has changed
- * (usually due to the user changing the selected modifier key(s) while dragging)
- * dragOver
is called when the cursor is moving over the drop target
- * dropAccept
is called just before the drop is performed. The drop target is given
- * the chance to change the nature of the drop or veto the drop by setting the event.detail
field
- * drop
is called when the data is being dropped
- *
+ * Returns the Control which is registered for this DropTarget. This is the control over which the
+ * user positions the cursor to drop the data.
*
- * @param listener the listener which should be notified
+ * @return the Control which is registered for this DropTarget
+ */
+public Control getControl () {
+ return control;
+}
+
+/**
+ * Returns an array of listeners who will be notified when a drag and drop
+ * operation is in progress, by sending it one of the messages defined in
+ * the DropTargetListener
interface.
*
- * @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the listener is null
- *
+ * @return the listeners who will be notified when a drag and drop
+ * operation is in progress
+ *
* @exception DWTException
* - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
* - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*
*
* @see DropTargetListener
+ * @see #addDropListener
* @see #removeDropListener
* @see DropTargetEvent
+ *
+ * @since 3.4
*/
-public void addDropListener(DropTargetListener listener) {
- if (listener is null) DND.error (DWT.ERROR_NULL_ARGUMENT);
- DNDListener typedListener = new DNDListener (listener);
- typedListener.dndWidget = this;
- addListener (DND.DragEnter, typedListener);
- addListener (DND.DragLeave, typedListener);
- addListener (DND.DragOver, typedListener);
- addListener (DND.DragOperationChanged, typedListener);
- addListener (DND.Drop, typedListener);
- addListener (DND.DropAccept, typedListener);
+public DropTargetListener[] getDropListeners() {
+ Listener[] listeners = getListeners(DND.DragEnter);
+ int length = listeners.length;
+ DropTargetListener[] dropListeners = new DropTargetListener[length];
+ int count = 0;
+ for (int i = 0; i < length; i++) {
+ Listener listener = listeners[i];
+ if (listener instanceof DNDListener) {
+ dropListeners[count] = (DropTargetListener) ((DNDListener) listener).getEventListener();
+ count++;
+ }
+ }
+ if (count is length) return dropListeners;
+ DropTargetListener[] result = new DropTargetListener[count];
+ System.arraycopy(dropListeners, 0, result, 0, count);
+ return result;
+}
+
+/**
+ * Returns the drop effect for this DropTarget. This drop effect will be
+ * used during a drag and drop to display the drag under effect on the
+ * target widget.
+ *
+ * @return the drop effect that is registered for this DropTarget
+ *
+ * @since 3.3
+ */
+public DropTargetEffect getDropTargetEffect() {
+ return dropEffect;
+}
+
+int getOperationFromKeyState() {
+ // The NSDraggingInfo object already combined the modifier keys with the
+ // drag source's allowed events. This might be better accomplished by diffing
+ // the base drag source mask with the active drag state mask instead of snarfing
+ // the current event.
+
+ // See documentation on [NSDraggingInfo draggingSourceOperationMask] for the
+ // correct Cocoa behavior. Control + Option or Command is NSDragOperationGeneric,
+ // or DND.DROP_DEFAULT in the DWT.
+ NSEvent currEvent = NSApplication.sharedApplication().currentEvent();
+ int /*long*/ modifiers = currEvent.modifierFlags();
+ bool option = (modifiers & OS.NSAlternateKeyMask) is OS.NSAlternateKeyMask;
+ bool control = (modifiers & OS.NSControlKeyMask) is OS.NSControlKeyMask;
+ if (control && option) return DND.DROP_DEFAULT;
+ if (control) return DND.DROP_LINK;
+ if (option) return DND.DROP_COPY;
+ return DND.DROP_DEFAULT;
}
-protected void checkSubclass () {
- String name = getClass().getName ();
- String validName = DropTarget.class.getName();
- if (!validName.opEquals(name)) {
- DND.error (DWT.ERROR_INVALID_SUBCLASS);
- }
+/**
+ * Returns a list of the data types that can be transferred to this DropTarget.
+ *
+ * @return a list of the data types that can be transferred to this DropTarget
+ */
+public Transfer[] getTransfer() {
+ return transferAgents;
+}
+
+void onDispose () {
+ if (control is null)
+ return;
+ if (controlListener !is null)
+ control.removeListener(DWT.Dispose, controlListener);
+ controlListener = null;
+ control.setData(DND.DROP_TARGET_KEY, null);
+ transferAgents = null;
+
+ // Unregister the control as a drop target.
+ control.view.unregisterDraggedTypes();
+ control = null;
}
-int dragReceiveHandler(int theWindow, int handlerRefCon, int theDrag) {
- updateDragOverHover(0, null);
- if (keyOperation is -1) return OS.dragNotAcceptedErr;
+int opToOsOp(int operation) {
+ int osOperation = 0;
+ if ((operation & DND.DROP_COPY) !is 0){
+ osOperation |= OS.NSDragOperationCopy;
+ }
+ if ((operation & DND.DROP_LINK) !is 0) {
+ osOperation |= OS.NSDragOperationLink;
+ }
+ if ((operation & DND.DROP_MOVE) !is 0) {
+ osOperation |= OS.NSDragOperationMove;
+ }
+ if ((operation & DND.DROP_TARGET_MOVE) !is 0) {
+ osOperation |= OS.NSDragOperationDelete;
+ }
+ return osOperation;
+}
+int osOpToOp(int /*long*/ osOperation){
+ int operation = 0;
+ if ((osOperation & OS.NSDragOperationCopy) !is 0){
+ operation |= DND.DROP_COPY;
+ }
+ if ((osOperation & OS.NSDragOperationLink) !is 0) {
+ operation |= DND.DROP_LINK;
+ }
+ if ((osOperation & OS.NSDragOperationDelete) !is 0) {
+ operation |= DND.DROP_TARGET_MOVE;
+ }
+ if ((osOperation & OS.NSDragOperationMove) !is 0) {
+ operation |= DND.DROP_MOVE;
+ }
+ if (osOperation is OS.NSDragOperationEvery) {
+ operation = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+ }
+ return operation;
+}
+
+bool performDragOperation(NSObject sender) {
DNDEvent event = new DNDEvent();
event.widget = this;
- event.time = cast(int)System.currentTimeMillis();
+ event.time = (int)System.currentTimeMillis();
+
+ if (dropEffect !is null) {
+ NSPoint mouseLocation = sender.draggingLocation();
+ NSPoint globalLoc = sender.draggingDestinationWindow().convertBaseToScreen(mouseLocation);
+ event.item = dropEffect.getItem((int)globalLoc.x, (int)globalLoc.y);
+ }
+
event.detail = DND.DROP_NONE;
notifyListeners(DND.DragLeave, event);
event = new DNDEvent();
- if (!setEventData(theDrag, event)) {
- return OS.dragNotAcceptedErr;
+ if (!setEventData(sender, event)) {
+ return false;
}
keyOperation = -1;
@@ -348,10 +591,9 @@
System.arraycopy(event.dataTypes, 0, allowedDataTypes, 0, event.dataTypes.length);
event.dataType = selectedDataType;
event.detail = selectedOperation;
+ notifyListeners(DND.DropAccept, event);
+
selectedDataType = null;
- selectedOperation = DND.DROP_NONE;
- notifyListeners(DND.DropAccept, event);
-
if (event.dataType !is null) {
for (int i = 0; i < allowedDataTypes.length; i++) {
if (allowedDataTypes[i].type is event.dataType.type) {
@@ -360,32 +602,56 @@
}
}
}
+
+ selectedOperation = DND.DROP_NONE;
if (selectedDataType !is null && (event.detail & allowedOperations) !is 0) {
selectedOperation = event.detail;
}
+
if (selectedOperation is DND.DROP_NONE) {
- // this was not a successful drop
- return OS.dragNotAcceptedErr;
+ return false;
}
+
// ask drag source for dropped data
- byte[][] data = new byte[0][];
- // locate all the items with data of the desired type
- short[] numItems = new short[1];
- OS.CountDragItems(theDrag, numItems);
- for (short i = 0; i < numItems[0]; i++) {
- int[] theItemRef = new int[1];
- OS.GetDragItemReferenceNumber(theDrag, cast(short) (i+1), theItemRef);
- int[] size = new int[1];
- OS.GetFlavorDataSize(theDrag, theItemRef[0], selectedDataType.type, size);
- if (size[0] > 0) {
- byte[] buffer = new byte[size[0]];
- OS.GetFlavorData(theDrag, theItemRef[0], selectedDataType.type, buffer, size, 0);
- byte[][] newData = new byte[data.length + 1][];
- System.arraycopy(data, 0, newData, 0, data.length);
- newData[data.length] = buffer;
- data = newData;
+ NSPasteboard pasteboard = sender.draggingPasteboard();
+ NSObject data = null;
+ NSMutableArray types = NSMutableArray.arrayWithCapacity(10);
+
+ for (int i = 0; i < transferAgents.length; i++){
+ Transfer transfer = transferAgents[i];
+ String[] typeNames = transfer.getTypeNames();
+ int[] typeIds = transfer.getTypeIds();
+
+ for (int j = 0; j < typeNames.length; j++) {
+ if (selectedDataType.type is typeIds[j]) {
+ types.addObject(NSString.stringWith(typeNames[j]));
+ break;
+ }
}
}
+
+ NSString type = pasteboard.availableTypeFromArray(types);
+ TransferData tdata = new TransferData();
+
+ if (type !is null) {
+ tdata.type = Transfer.registerType(type.getString());
+ if (type.isEqual(OS.NSStringPboardType) ||
+ type.isEqual(OS.NSHTMLPboardType) ||
+ type.isEqual(OS.NSRTFPboardType)) {
+ tdata.data = pasteboard.stringForType(type);
+ } else if (type.isEqual(OS.NSURLPboardType)) {
+ tdata.data = NSURL.URLFromPasteboard(pasteboard);
+ } else if (type.isEqual(OS.NSFilenamesPboardType)) {
+ tdata.data = new NSArray(pasteboard.propertyListForType(type).id);
+ } else {
+ tdata.data = pasteboard.dataForType(type);
+ }
+ }
+
+ if (tdata.data !is null) {
+ data = tdata.data;
+ }
+
// Get Data in a Java format
Object object = null;
for (int i = 0; i < transferAgents.length; i++) {
@@ -410,230 +676,14 @@
selectedOperation = event.detail;
}
//notify source of action taken
- int action = opToOsOp(selectedOperation);
- OS.SetDragDropAction(theDrag, action);
- return (selectedOperation is DND.DROP_NONE) ? OS.dragNotAcceptedErr : OS.noErr;
-}
-
-int dragTrackingHandler(int message, int theWindow, int handlerRefCon, int theDrag) {
-
- if (message is OS.kDragTrackingLeaveWindow) {
- updateDragOverHover(0, null);
- OS.SetThemeCursor(OS.kThemeArrowCursor);
- if (keyOperation is -1) return OS.dragNotAcceptedErr;
- keyOperation = -1;
-
- DNDEvent event = new DNDEvent();
- event.widget = this;
- event.time = cast(int)System.currentTimeMillis();
- event.detail = DND.DROP_NONE;
- notifyListeners(DND.DragLeave, event);
- return OS.noErr;
- }
-
- int oldKeyOperation = keyOperation;
-
- if (message is OS.kDragTrackingEnterWindow) {
- selectedDataType = null;
- selectedOperation = 0;
- }
-
- DNDEvent event = new DNDEvent();
- if (!setEventData(theDrag, event)) {
- keyOperation = -1;
- OS.SetThemeCursor(OS.kThemeNotAllowedCursor);
- return OS.dragNotAcceptedErr;
- }
-
- int allowedOperations = event.operations;
- TransferData[] allowedDataTypes = new TransferData[event.dataTypes.length];
- System.arraycopy(event.dataTypes, 0, allowedDataTypes, 0, allowedDataTypes.length);
-
- switch (message) {
- case OS.kDragTrackingEnterWindow:
- event.type = DND.DragEnter;
- break;
- case OS.kDragTrackingInWindow:
- if (keyOperation is oldKeyOperation) {
- event.type = DND.DragOver;
- event.dataType = selectedDataType;
- event.detail = selectedOperation;
- }else {
- event.type = DND.DragOperationChanged;
- event.dataType = selectedDataType;
- }
- break;
- }
-
- updateDragOverHover(DRAGOVER_HYSTERESIS, event);
- selectedDataType = null;
- selectedOperation = DND.DROP_NONE;
- notifyListeners(event.type, event);
-
- if (event.detail is DND.DROP_DEFAULT) {
- event.detail = (allowedOperations & DND.DROP_MOVE) !is 0 ? DND.DROP_MOVE : DND.DROP_NONE;
- }
-
- if (event.dataType !is null) {
- for (int i = 0; i < allowedDataTypes.length; i++) {
- if (allowedDataTypes[i].type is event.dataType.type) {
- selectedDataType = allowedDataTypes[i];
- break;
- }
- }
- }
-
- if (selectedDataType !is null && (allowedOperations & event.detail) !is 0) {
- selectedOperation = event.detail;
- }
-
- OS.SetDragDropAction(theDrag, opToOsOp(selectedOperation));
-
- switch (selectedOperation) {
- case DND.DROP_COPY:
- OS.SetThemeCursor(OS.kThemeCopyArrowCursor);
- break;
- case DND.DROP_LINK:
- OS.SetThemeCursor(OS.kThemeAliasArrowCursor);
- break;
- case DND.DROP_MOVE:
- OS.SetThemeCursor(OS.kThemeArrowCursor);
- break;
- default:
- OS.SetThemeCursor(OS.kThemeNotAllowedCursor);
- }
-
- if (message is OS.kDragTrackingEnterWindow) {
- dragOverHeartbeat.run();
- }
- return OS.noErr;
-}
-
-/**
- * Returns the Control which is registered for this DropTarget. This is the control over which the
- * user positions the cursor to drop the data.
- *
- * @return the Control which is registered for this DropTarget
- */
-public Control getControl () {
- return control;
-}
-
-/**
- * Returns an array of listeners who will be notified when a drag and drop
- * operation is in progress, by sending it one of the messages defined in
- * the DropTargetListener
interface.
- *
- * @exception DWTException
- * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- *
- * @see DropTargetListener
- * @see #addDropListener
- * @see #removeDropListener
- * @see DropTargetEvent
- *
- * @since 3.4
- */
-public DropTargetListener[] getDropListeners() {
- Listener[] listeners = getListeners(DND.DragEnter);
- int length = listeners.length;
- DropTargetListener[] dropListeners = new DropTargetListener[length];
- int count = 0;
- for (int i = 0; i < length; i++) {
- Listener listener = listeners[i];
- if ( null !is cast(DNDListener)listener ) {
- dropListeners[count] = cast(DropTargetListener) (cast(DNDListener) listener).getEventListener();
- count++;
- }
- }
- if (count is length) return dropListeners;
- DropTargetListener[] result = new DropTargetListener[count];
- System.arraycopy(dropListeners, 0, result, 0, count);
- return result;
-}
-
-/**
- * Returns the drop effect for this DropTarget. This drop effect will be
- * used during a drag and drop to display the drag under effect on the
- * target widget.
- *
- * @return the drop effect that is registered for this DropTarget
- *
- * @since 3.3
- */
-public DropTargetEffect getDropTargetEffect() {
- return dropEffect;
-}
-
-int getOperationFromKeyState(int theDrag) {
- short[] modifiers = new short[1];
- OS.GetDragModifiers(theDrag, modifiers, null, null);
- bool option = (modifiers[0] & OS.optionKey) is OS.optionKey;
- bool command = (modifiers[0] & OS.cmdKey) is OS.cmdKey;
- if (option && command) return DND.DROP_LINK;
- if (option) return DND.DROP_COPY;
- if (command) return DND.DROP_MOVE;
- return DND.DROP_DEFAULT;
-}
-
-/**
- * Returns a list of the data types that can be transferred to this DropTarget.
- *
- * @return a list of the data types that can be transferred to this DropTarget
- */
-public Transfer[] getTransfer() {
- return transferAgents;
-}
-
-void onDispose () {
- if (control is null)
- return;
- if (controlListener !is null)
- control.removeListener(DWT.Dispose, controlListener);
- controlListener = null;
- control.setData(DND.DROP_TARGET_KEY, null);
- transferAgents = null;
- control = null;
-}
-
-int opToOsOp(int operation) {
- int osOperation = 0;
- if ((operation & DND.DROP_COPY) !is 0){
- osOperation |= OS.kDragActionCopy;
- }
- if ((operation & DND.DROP_LINK) !is 0) {
- osOperation |= OS.kDragActionAlias;
- }
- if ((operation & DND.DROP_MOVE) !is 0) {
- osOperation |= OS.kDragActionMove;
- }
- return osOperation;
-}
-
-int osOpToOp(int osOperation){
- int operation = 0;
- if ((osOperation & OS.kDragActionCopy) !is 0){
- operation |= DND.DROP_COPY;
- }
- if ((osOperation & OS.kDragActionAlias) !is 0) {
- operation |= DND.DROP_LINK;
- }
- if ((osOperation & OS.kDragActionMove) !is 0) {
- operation |= DND.DROP_MOVE;
- }
- if (osOperation is OS.kDragActionAll) {
- operation = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- }
- return operation;
+ return (selectedOperation !is DND.DROP_NONE);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when a drag and drop operation is in progress.
*
- * @param listener the listener which should be notified
+ * @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException
* - ERROR_NULL_ARGUMENT - if the listener is null
@@ -645,6 +695,7 @@
*
* @see DropTargetListener
* @see #addDropListener
+ * @see #getDropListeners
*/
public void removeDropListener(DropTargetListener listener) {
if (listener is null) DND.error (DWT.ERROR_NULL_ARGUMENT);
@@ -669,18 +720,17 @@
dropEffect = effect;
}
-bool setEventData(int theDrag, DNDEvent event) {
- if (theDrag is 0) return false;
+bool setEventData(NSObject draggingState, DNDEvent event) {
+ if (draggingState is null) return false;
// get allowed operations
int style = getStyle();
- int[] outActions = new int[1];
- OS.GetDragAllowableActions(theDrag, outActions);
- int operations = osOpToOp(outActions[0]) & style;
+ int /*long*/ allowedActions = draggingState.draggingSourceOperationMask();
+ int operations = osOpToOp(allowedActions) & style;
if (operations is DND.DROP_NONE) return false;
-
- //get current operation
- int operation = getOperationFromKeyState(theDrag);
+
+ // get current operation
+ int operation = getOperationFromKeyState();
keyOperation = operation;
if (operation is DND.DROP_DEFAULT) {
if ((style & DND.DROP_DEFAULT) is 0) {
@@ -690,53 +740,27 @@
if ((operation & operations) is 0) operation = DND.DROP_NONE;
}
+
// get allowed transfer types
- short[] numItems = new short[1];
- OS.CountDragItems(theDrag, numItems);
- int[] flavors = new int[10];
+ NSPasteboard dragPBoard = draggingState.draggingPasteboard();
+ NSArray draggedTypes = dragPBoard.types();
+ if (draggedTypes is null) return false;
+
+ int /*long*/ draggedTypeCount = draggedTypes.count();
+
+ TransferData[] dataTypes = new TransferData[(int)draggedTypeCount];
int index = -1;
- //Get a unique list of flavors
- for (short i = 0; i < numItems[0]; i++) {
- int[] theItemRef = new int[1];
- OS.GetDragItemReferenceNumber(theDrag, cast(short) (i+1), theItemRef);
- short[] numFlavors = new short[1];
- OS.CountDragItemFlavors(theDrag, theItemRef[0], numFlavors);
- int[] theType = new int[1];
- for (int j = 0; j < numFlavors[0]; j++) {
- theType[0] = 0;
- if (OS.GetFlavorType(theDrag, theItemRef[0], cast(short) (j+1), theType) is OS.noErr) {
- bool unique = true;
- for (int k = 0; k < flavors.length; k++) {
- if (flavors[k] is theType[0]) {
- unique = false;
- break;
- }
- }
- if (unique) {
- if (index is flavors.length - 1) {
- int[] temp = new int[flavors.length + 10];
- System.arraycopy(flavors, 0, temp, 0, flavors.length);
- flavors = temp;
- }
- flavors[++index] = theType[0];
- }
- }
- }
- }
- if (index is -1) return false;
-
- TransferData[] dataTypes = new TransferData[index+1];
- index = -1;
- for (int i = 0; i < dataTypes.length; i++) {
- if (flavors[i] !is 0) {
- TransferData data = new TransferData();
- data.type = flavors[i];
- for (int j = 0; j < transferAgents.length; j++) {
- Transfer transfer = transferAgents[j];
- if (transfer !is null && transfer.isSupportedType(data)) {
- dataTypes[++index] = data;
- break;
- }
+ for (int i = 0; i < draggedTypeCount; i++) {
+ id draggedType = draggedTypes.objectAtIndex(i);
+ NSString nativeDataType = new NSString(draggedType);
+ TransferData data = new TransferData();
+ data.type = Transfer.registerType(nativeDataType.getString());
+
+ for (int j = 0; j < transferAgents.length; j++) {
+ Transfer transfer = transferAgents[j];
+ if (transfer !is null && transfer.isSupportedType(data)) {
+ dataTypes[++index] = data;
+ break;
}
}
}
@@ -748,13 +772,17 @@
dataTypes = temp;
}
- Point mouse = new Point();
- OS.GetDragMouse(theDrag, mouse, null);
+ // Convert from window-relative to global coordinates, and flip it.
+ NSPoint mouse = draggingState.draggingLocation();
+ NSPoint globalMouse = draggingState.draggingDestinationWindow().convertBaseToScreen(mouse);
+ NSArray screens = NSScreen.screens();
+ NSRect screenRect = new NSScreen(screens.objectAtIndex(0)).frame();
+ globalMouse.y = screenRect.height - globalMouse.y;
event.widget = this;
- event.x = mouse.h;
- event.y = mouse.v;
- event.time = cast(int)System.currentTimeMillis();
+ event.x = (int)globalMouse.x;
+ event.y = (int)globalMouse.y;
+ event.time = (int)System.currentTimeMillis();
event.feedback = DND.FEEDBACK_SELECT;
event.dataTypes = dataTypes;
event.dataType = dataTypes[0];
@@ -783,22 +811,35 @@
public void setTransfer(Transfer[] transferAgents){
if (transferAgents is null) DND.error(DWT.ERROR_NULL_ARGUMENT);
this.transferAgents = transferAgents;
+
+
+ // Register the types as valid drop types in Cocoa.
+ // Accumulate all of the transfer types into a list.
+ ArrayList typeStrings = new ArrayList();
+
+ for (int i = 0; i < this.transferAgents.length; i++) {
+ String[] types = transferAgents[i].getTypeNames();
+
+ for (int j = 0; j < types.length; j++) {
+ typeStrings.add(types[j]);
+ }
+ }
+
+ // Convert to an NSArray of NSStrings so we can register with the Control.
+ int typeStringCount = typeStrings.size();
+ NSMutableArray nsTypeStrings = NSMutableArray.arrayWithCapacity(typeStringCount);
+
+ for (int i = 0; i < typeStringCount; i++) {
+ nsTypeStrings.addObject(NSString.stringWith((String)typeStrings.get(i)));
+ }
+
+ control.view.registerForDraggedTypes(nsTypeStrings);
+
}
-void updateDragOverHover(long delay, DNDEvent event) {
- if (delay is 0) {
- dragOverStart = 0;
- dragOverEvent = null;
- return;
- }
- dragOverStart = System.currentTimeMillis() + delay;
- if (dragOverEvent is null) dragOverEvent = new DNDEvent();
- dragOverEvent.x = event.x;
- dragOverEvent.y = event.y;
- dragOverEvent.dataTypes = event.dataTypes;
- dragOverEvent.operations = event.operations;
- dragOverEvent.dataType = event.dataType;
- dragOverEvent.detail = event.detail;
+// By returning true we get draggingUpdated messages even when the mouse isn't moving.
+bool wantsPeriodicDraggingUpdates() {
+ return true;
}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DropTargetAdapter.d
--- a/dwt/dnd/DropTargetAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DropTargetAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2004 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
@@ -8,7 +8,9 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DropTargetAdapter;
+
+import dwt.dwthelper.utils;
/**
@@ -22,45 +24,63 @@
*
* @see DropTargetListener
* @see DropTargetEvent
+ * @see Sample code and further information
*/
-public class DropTargetAdapter : DropTargetListener {
+public class DropTargetAdapter implements DropTargetListener {
/**
* This implementation of dragEnter
permits the default
* operation defined in event.detail
to be performed on the current data type
* defined in event.currentDataType
.
* For additional information see DropTargetListener.dragEnter
.
+ *
+ * @param event the information associated with the drag enter event
*/
public void dragEnter(DropTargetEvent event){}
+
/**
* This implementation of dragLeave
does nothing.
* For additional information see DropTargetListener.dragOperationChanged
.
+ *
+ * @param event the information associated with the drag leave event
*/
public void dragLeave(DropTargetEvent event){}
+
/**
* This implementation of dragOperationChanged
permits the default
* operation defined in event.detail
to be performed on the current data type
* defined in event.currentDataType
.
* For additional information see DropTargetListener.dragOperationChanged
.
+ *
+ * @param event the information associated with the drag operation changed event
*/
public void dragOperationChanged(DropTargetEvent event){}
+
/**
* This implementation of dragOver
permits the default
* operation defined in event.detail
to be performed on the current data type
* defined in event.currentDataType
.
* For additional information see DropTargetListener.dragOver
.
+ *
+ * @param event the information associated with the drag over event
*/
public void dragOver(DropTargetEvent event){}
+
/**
* This implementation of drop
does nothing.
* For additional information see DropTargetListener.drop
.
+ *
+ * @param event the information associated with the drop event
*/
public void drop(DropTargetEvent event){}
+
/**
* This implementation of dropAccept
permits the default
* operation defined in event.detail
to be performed on the current data type
* defined in event.currentDataType
.
* For additional information see DropTargetListener.dropAccept
.
+ *
+ * @param event the information associated with the drop accept event
*/
public void dropAccept(DropTargetEvent event){}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DropTargetEffect.d
--- a/dwt/dnd/DropTargetEffect.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DropTargetEffect.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 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
@@ -8,11 +8,19 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DropTargetEffect;
+
+import dwt.dwthelper.utils;
-import dwt.*;
-import dwt.graphics.*;
-import dwt.widgets.*;
+import dwt.DWT;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Control;
+import dwt.widgets.Table;
+import dwt.widgets.TableItem;
+import dwt.widgets.Tree;
+import dwt.widgets.TreeItem;
+import dwt.widgets.Widget;
/**
@@ -44,10 +52,11 @@
*
* @see DropTargetAdapter
* @see DropTargetEvent
+ * @see Sample code and further information
*
* @since 3.3
*/
-public class DropTargetEffect : DropTargetAdapter {
+public class DropTargetEffect extends DropTargetAdapter {
Control control;
/**
@@ -60,7 +69,7 @@
* - ERROR_NULL_ARGUMENT - if the control is null
*
*/
- public this(Control control) {
+ public DropTargetEffect(Control control) {
if (control is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
this.control = control;
}
@@ -85,11 +94,11 @@
* @return the item at the given x-y coordinate, or null if the coordinate is not in a selectable item
*/
public Widget getItem(int x, int y) {
- if ( null !is cast(Table)control ) {
- return getItem(cast(Table) control, x, y);
+ if (control instanceof Table) {
+ return getItem((Table) control, x, y);
}
- if ( null !is cast(Tree)control ) {
- return getItem(cast(Tree) control, x, y);
+ if (control instanceof Tree) {
+ return getItem((Tree) control, x, y);
}
return null;
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DropTargetEvent.d
--- a/dwt/dnd/DropTargetEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DropTargetEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -8,15 +8,19 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DropTargetEvent;
+
+import dwt.dwthelper.utils;
import dwt.events.TypedEvent;
import dwt.widgets.Widget;
/**
* The DropTargetEvent contains the event information passed in the methods of the DropTargetListener.
+ *
+ * @see Sample code and further information
*/
-public class DropTargetEvent : TypedEvent {
+public class DropTargetEvent extends TypedEvent {
/**
* The x-cordinate of the cursor relative to the Display
*/
@@ -87,7 +91,7 @@
*
* @param e the untyped event containing the information
*/
-public this(DNDEvent e) {
+public DropTargetEvent(DNDEvent e) {
super(e);
this.data = e.data;
this.x = e.x;
@@ -112,4 +116,31 @@
e.feedback = this.feedback;
e.item = this.item;
}
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+ String string = super.toString ();
+ StringBuffer sb = new StringBuffer();
+ sb.append(string.substring (0, string.length() - 1)); // remove trailing '}'
+ sb.append(" x="); sb.append(x);
+ sb.append(" y="); sb.append(y);
+ sb.append(" item="); sb.append(item);
+ sb.append(" operations="); sb.append(operations);
+ sb.append(" operation="); sb.append(detail);
+ sb.append(" feedback="); sb.append(feedback);
+ sb.append(" dataTypes={ ");
+ if (dataTypes !is null) {
+ for (int i = 0; i < dataTypes.length; i++) {
+ sb.append(dataTypes[i].type); sb.append(' ');
+ }
+ }
+ sb.append('}');
+ sb.append(" currentDataType="); sb.append(currentDataType !is null ? currentDataType.type : '0');
+ sb.append('}');
+ return sb.toString();
}
+}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/DropTargetListener.d
--- a/dwt/dnd/DropTargetListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/DropTargetListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -8,7 +8,9 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.DropTargetListener;
+
+import dwt.dwthelper.utils;
import dwt.internal.DWTEventListener;
@@ -33,7 +35,7 @@
* @see DropTargetEvent
*
*/
-public interface DropTargetListener : DWTEventListener {
+public interface DropTargetListener extends DWTEventListener {
/**
* The cursor has entered the drop target boundaries.
@@ -176,9 +178,9 @@
*
* public void dragOver(DropTargetEvent event) {
* TextTransfer textTransfer = TextTransfer.getInstance();
- * String data = cast(String)textTransfer.nativeToJava(event.currentDataType);
+ * String data = (String)textTransfer.nativeToJava(event.currentDataType);
* if (data !is null) {
- * System.out.println("Data to be dropped is cast(Text)"+data);
+ * System.out.println("Data to be dropped is (Text)"+data);
* }
* };
*
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/FileTransfer.d
--- a/dwt/dnd/FileTransfer.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/FileTransfer.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 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
@@ -9,10 +9,14 @@
* IBM Corporation - initial API and implementation
* Outhink - support for typeFileURL
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.FileTransfer;
+
+import dwt.dwthelper.utils;
-import java.io.*;
-import dwt.internal.carbon.*;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSMutableArray;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
/**
* The class FileTransfer
provides a platform specific mechanism
@@ -20,7 +24,6 @@
* platform specific representation of the data and vice versa.
* Each String
in the array contains the absolute path for a single
* file or directory.
- * See Transfer
for additional information.
*
* An example of a java String[]
containing a list of files is shown
* below:
@@ -32,16 +35,16 @@
* fileData[0] = file1.getAbsolutePath();
* fileData[1] = file2.getAbsolutePath();
*
+ *
+ * @see Transfer
*/
-public class FileTransfer : ByteArrayTransfer {
+public class FileTransfer extends ByteArrayTransfer {
static FileTransfer _instance = new FileTransfer();
- static final String HFS = "hfs "; //$NON-NLS-1$
- static final String FURL = "furl"; //$NON-NLS-1$
- static final int HFSID = registerType(HFS);
- static final int FURLID = registerType(FURL);
+ static final String ID_NAME = OS.NSFilenamesPboardType.getString();
+ static final int ID = registerType(ID_NAME);
-this() {}
+FileTransfer() {}
/**
* Returns the singleton instance of the FileTransfer class.
@@ -56,136 +59,65 @@
* This implementation of javaToNative
converts a list of file names
* represented by a java String[]
to a platform specific representation.
* Each String
in the array contains the absolute path for a single
- * file or directory. For additional information see
- * Transfer#javaToNative
.
+ * file or directory.
*
- * @param object a java String[]
containing the file names to be
- * converted
- * @param transferData an empty TransferData
object; this
- * object will be filled in on return with the platform specific format of the data
+ * @param object a java String[]
containing the file names to be converted
+ * @param transferData an empty TransferData
object that will
+ * be filled in on return with the platform specific format of the data
+ *
+ * @see Transfer#nativeToJava
*/
public void javaToNative(Object object, TransferData transferData) {
if (!checkFile(object) || !isSupportedType(transferData)) {
DND.error(DND.ERROR_INVALID_DATA);
}
String[] files = (String[])object;
- transferData.result = -1;
- byte[][] data = new byte[files.length][];
- for (int i = 0; i < data.length; i++) {
- File file = new File(files[i]);
- bool isDirectory = file.isDirectory();
+ int length = files.length;
+ NSMutableArray array = NSMutableArray.arrayWithCapacity(length);
+ for (int i = 0; i < length; i++) {
String fileName = files[i];
- char [] chars = new char [fileName.length ()];
- fileName.getChars (0, chars.length, chars, 0);
- int cfString = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, chars, chars.length);
- if (cfString is 0) return;
- try {
- int url = OS.CFURLCreateWithFileSystemPath(OS.kCFAllocatorDefault, cfString, OS.kCFURLPOSIXPathStyle, isDirectory);
- if (url is 0) return;
- try {
- if (transferData.type is HFSID) {
- byte[] fsRef = new byte[80];
- if (!OS.CFURLGetFSRef(url, fsRef)) return;
- byte[] fsSpec = new byte[70];
- if (OS.FSGetCatalogInfo(fsRef, 0, null, null, fsSpec, null) !is OS.noErr) return;
- byte[] hfsflavor = new byte[10 + fsSpec.length];
- byte[] finfo = new byte[16];
- OS.FSpGetFInfo(fsSpec, finfo);
- System.arraycopy(finfo, 0, hfsflavor, 0, 10);
- System.arraycopy(fsSpec, 0, hfsflavor, 10, fsSpec.length);
- data[i] = hfsflavor;
- }
- if (transferData.type is FURLID) {
- int encoding = OS.CFStringGetSystemEncoding();
- int theData = OS.CFURLCreateData(OS.kCFAllocatorDefault, url, encoding, true);
- if (theData is 0) return;
- try {
- int length = OS.CFDataGetLength(theData);
- byte[] buffer = new byte[length];
- CFRange range = new CFRange();
- range.length = length;
- OS.CFDataGetBytes(theData, range, buffer);
- data[i] = buffer;
- } finally {
- OS.CFRelease(theData);
- }
- }
- } finally {
- OS.CFRelease(url);
- }
- } finally {
- OS.CFRelease(cfString);
- }
+ NSString string = NSString.stringWith(fileName);
+ array.addObject(string);
}
- transferData.data = data;
- transferData.result = 0;
+ transferData.data = array;
}
/**
* This implementation of nativeToJava
converts a platform specific
* representation of a list of file names to a java String[]
.
* Each String in the array contains the absolute path for a single file or directory.
- * For additional information see Transfer#nativeToJava
.
*
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java String[]
containing a list of file names if the
- * conversion was successful; otherwise null
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java String[]
containing a list of file names if the conversion
+ * was successful; otherwise null
+ *
+ * @see Transfer#javaToNative
*/
public Object nativeToJava(TransferData transferData) {
if (!isSupportedType(transferData) || transferData.data is null) return null;
- if (transferData.data.length is 0) return null;
- int count = transferData.data.length;
+ NSArray array = (NSArray) transferData.data;
+ if (array.count() is 0) return null;
+ int count = (int)/*64*/array.count();
String[] fileNames = new String[count];
for (int i=0; iHTMLTransfer provides a platform specific mechanism
* for converting text in HTML format represented as a java String
- * to a platform specific representation of the data and vice versa. See
- * Transfer
for additional information.
+ * to a platform specific representation of the data and vice versa.
*
* An example of a java String
containing HTML text is shown
* below:
@@ -24,14 +26,16 @@
*
* String htmlData = "This is a paragraph of text.
";
*
+ *
+ * @see Transfer
*/
-public class HTMLTransfer : ByteArrayTransfer {
+public class HTMLTransfer extends ByteArrayTransfer {
static HTMLTransfer _instance = new HTMLTransfer();
- static final String HTML = "HTML"; //$NON-NLS-1$
+ static final String HTML = OS.NSHTMLPboardType.getString();
static final int HTMLID = registerType(HTML);
-this() {}
+HTMLTransfer() {}
/**
* Returns the singleton instance of the HTMLTransfer class.
@@ -45,44 +49,34 @@
/**
* This implementation of javaToNative
converts HTML-formatted text
* represented by a java String
to a platform specific representation.
- * For additional information see Transfer#javaToNative
.
*
* @param object a java String
containing HTML text
- * @param transferData an empty TransferData
object; this
- * object will be filled in on return with the platform specific format of the data
+ * @param transferData an empty TransferData
object that will
+ * be filled in on return with the platform specific format of the data
+ *
+ * @see Transfer#nativeToJava
*/
public void javaToNative (Object object, TransferData transferData){
if (!checkHTML(object) || !isSupportedType(transferData)) {
DND.error(DND.ERROR_INVALID_DATA);
}
- String String = cast(String)object;
- int count = String.length();
- char[] chars = new char[count];
- String.getChars(0, count, chars, 0);
- byte[] buffer = new byte[chars.length * 2];
- OS.memmove(buffer, chars, buffer.length);
- transferData.data = new byte[1][];
- transferData.data[0] = buffer;
- transferData.result = OS.noErr;
+ transferData.data = NSString.stringWith((String) object);
}
/**
* This implementation of nativeToJava
converts a platform specific
* representation of HTML text to a java String
.
- * For additional information see Transfer#nativeToJava
.
*
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java String
containing HTML text if the
- * conversion was successful; otherwise null
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java String
containing HTML text if the conversion was successful;
+ * otherwise null
+ *
+ * @see Transfer#javaToNative
*/
public Object nativeToJava(TransferData transferData){
if (!isSupportedType(transferData) || transferData.data is null) return null;
- if (transferData.data.length is 0 || transferData.data[0].length is 0) return null;
- byte[] buffer = transferData.data[0];
- char[] chars = new char[(buffer.length + 1) / 2];
- OS.memmove(chars, buffer, buffer.length);
- return new String(chars);
+ NSString string = (NSString) transferData.data;
+ return string.getString();
}
protected int[] getTypeIds() {
@@ -94,7 +88,7 @@
}
bool checkHTML(Object object) {
- return (object !is null && null !is cast(String)object && (cast(String)object).length() > 0);
+ return (object !is null && object instanceof String && ((String)object).length() > 0);
}
protected bool validate(Object object) {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/ImageTransfer.d
--- a/dwt/dnd/ImageTransfer.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/ImageTransfer.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 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
@@ -9,44 +9,46 @@
* IBM Corporation - initial API and implementation
* Outhink - support for typeFileURL
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.ImageTransfer;
+
+import dwt.dwthelper.utils;
import dwt.DWT;
-import dwt.graphics.*;
-import dwt.internal.carbon.*;
-import dwt.widgets.*;
+import dwt.graphics.Image;
+import dwt.graphics.ImageData;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.OS;
+import dwt.widgets.Display;
/**
- * The class ImageTransfer
provides a platform specific mechanism
- * for converting an Image represented as a java ImageData
to a
- * platform specific representation of the data and vice versa. The
- * ImageData
contains infomration about the Image. See
- * Transfer
for additional information.
+ * The class ImageTransfer
provides a platform specific mechanism
+ * for converting an Image represented as a java ImageData
to a
+ * platform specific representation of the data and vice versa.
*
- *
- * An example of a java Image
containing an ImageData is shown
- * below:
- *
+ * An example of a java ImageData
is shown below:
*
*
- * Image image = new Image(display, fileName);
- * ImageData imgData = image.getImageData();
+ * Image image = new Image(display, "C:\temp\img1.gif");
+ * ImageData imgData = image.getImageData();
*
+ *
+ * @see Transfer
+ *
+ * @since 3.4
*/
-public class ImageTransfer : ByteArrayTransfer {
+public class ImageTransfer extends ByteArrayTransfer {
static ImageTransfer _instance = new ImageTransfer();
-static final String PICT = "PICT"; //$NON-NLS-1$
-static final String TIFF = "TIFF"; //$NON-NLS-1$
-static final int PICTID = registerType(PICT);
+static final String TIFF = OS.NSTIFFPboardType.getString();
static final int TIFFID = registerType(TIFF);
-this() {
+ImageTransfer() {
}
/**
* Returns the singleton instance of the ImageTransfer class.
- *
+ *
* @return the singleton instance of the ImageTransfer class
*/
public static ImageTransfer getInstance() {
@@ -54,153 +56,59 @@
}
/**
- * This implementation of javaToNative
converts an ImageData
- * object represented by a java ImageData
to a platform
- * specific representation. For additional information see
- * Transfer#javaToNative
.
+ * This implementation of javaToNative
converts an ImageData object represented
+ * by java ImageData
to a platform specific representation.
*
- * @param object
- * a java ImageData
- * @param transferData
- * an empty TransferData
object; this object will
- * be filled in on return with the platform specific format of
- * the data
+ * @param object a java ImageData
containing the ImageData to be converted
+ * @param transferData an empty TransferData
object that will
+ * be filled in on return with the platform specific format of the data
+ *
+ * @see Transfer#nativeToJava
*/
public void javaToNative(Object object, TransferData transferData) {
if (!checkImage(object) || !isSupportedType(transferData)) {
DND.error(DND.ERROR_INVALID_DATA);
}
- transferData.result = -1;
-
- ImageData imgData = cast(ImageData) object;
+ ImageData imgData = (ImageData) object;
Image image = new Image(Display.getCurrent(), imgData);
- int handle = image.handle;
- int width = OS.CGImageGetWidth(handle);
- int height = OS.CGImageGetHeight(handle);
- int alphaInfo = OS.CGImageGetAlphaInfo(handle);
- int bpr = OS.CGImageGetBytesPerRow(handle);
-
- Rect rect = new Rect();
- rect.left = 0;
- rect.top = 0;
- rect.right = cast(short) width;
- rect.bottom = cast(short) height;
-
- int[] gWorld = new int[1];
- int format = OS.k24RGBPixelFormat;
- if (alphaInfo !is OS.kCGImageAlphaNoneSkipFirst) {
- format = OS.k32ARGBPixelFormat;
- }
- OS.NewGWorldFromPtr(gWorld, format, rect, 0, 0, 0, image.data, bpr);
- int[] curPort = new int[1];
- int[] curGWorld = new int[1];
- OS.GetGWorld(curPort, curGWorld);
- OS.SetGWorld(gWorld[0], curGWorld[0]);
- int pictHandle = OS.OpenPicture(rect);
- int portBitMap = OS.GetPortBitMapForCopyBits(gWorld[0]);
- OS.CopyBits(portBitMap, portBitMap, rect, rect, cast(short) OS.srcCopy, 0);
- OS.ClosePicture();
- OS.SetGWorld(curPort[0], curGWorld[0]);
- OS.DisposeGWorld(gWorld[0]);
- int length = OS.GetHandleSize(pictHandle);
- OS.HLock(pictHandle);
- int[] buffer = new int[1];
- OS.memmove(buffer, pictHandle, 4);
- byte[] pictData = new byte[length];
- OS.memmove(pictData, buffer[0], length);
- OS.HUnlock(pictHandle);
- OS.KillPicture(pictHandle);
+ NSImage handle = image.handle;
+ transferData.data = handle.TIFFRepresentation();
image.dispose();
-
- transferData.data = new byte[][] { pictData };
- transferData.result = OS.noErr;
}
/**
- * This implementation of nativeToJava
converts a platform
- * specific representation of an ImageData ImageData
. For
- * additional information see Transfer#nativeToJava
.
+ * This implementation of nativeToJava
converts a platform specific
+ * representation of an image to java ImageData
.
*
- * @param transferData
- * the platform specific representation of the data to be been
- * converted
- * @return a java ImageData
object if the conversion was
- * successful; otherwise null
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java ImageData
of the image if the conversion was successful;
+ * otherwise null
+ *
+ * @see Transfer#javaToNative
*/
public Object nativeToJava(TransferData transferData) {
- if (!isSupportedType(transferData) || transferData.data is null)
- return null;
- if (transferData.data.length is 0)
- return null;
- byte[] dataArr = transferData.data[0];
- int size = dataArr.length;
- int pictPtr = OS.NewPtr(size);
- OS.memmove(pictPtr, dataArr, size);
- int dataProvider = OS.CGDataProviderCreateWithData(0, pictPtr, size, 0);
- if (dataProvider !is 0) {
- int pictDataRef = OS.QDPictCreateWithProvider(dataProvider);
- // get bounds for the image
- CGRect rect = new CGRect();
- OS.QDPictGetBounds(pictDataRef, rect);
- int width = cast(int) rect.width;
- int height = cast(int) rect.height;
-
- /* Create the image */
- int bpr = width * 4;
- int dataSize = height * bpr;
- int data = OS.NewPtr(dataSize);
- if (data is 0)
- DWT.error(DWT.ERROR_NO_HANDLES);
- int provider = OS
- .CGDataProviderCreateWithData(0, data, dataSize, 0);
- if (provider is 0) {
- OS.DisposePtr(data);
- DWT.error(DWT.ERROR_NO_HANDLES);
- }
- int colorspace = OS.CGColorSpaceCreateDeviceRGB();
- if (colorspace is 0)
- DWT.error(DWT.ERROR_NO_HANDLES);
- int handle = OS.CGImageCreate(width, height, 8, 32, bpr,
- colorspace, OS.kCGImageAlphaNoneSkipFirst, provider, null,
- true, 0);
- OS.CGDataProviderRelease(provider);
- if (handle is 0) {
- OS.DisposePtr(data);
- DWT.error(DWT.ERROR_NO_HANDLES);
- }
- int bpc = OS.CGImageGetBitsPerComponent(handle);
- int context = OS.CGBitmapContextCreate(data, width, height, bpc,
- bpr, colorspace, OS.kCGImageAlphaNoneSkipFirst);
- if (context is 0) {
- OS.CGImageRelease(handle);
- OS.DisposePtr(data);
- DWT.error(DWT.ERROR_NO_HANDLES);
- }
- int status = OS.QDPictDrawToCGContext(context, rect, pictDataRef);
- ImageData imgData = null;
- if (status is 0) {
- Image image = Image.carbon_new(Display.getCurrent(),
- DWT.BITMAP, handle, data);
- imgData = image.getImageData();
- image.dispose();
- }
- OS.CGContextRelease(context);
- OS.QDPictRelease(pictDataRef);
- return imgData;
- }
- return null;
+ if (!isSupportedType(transferData) || transferData.data is null) return null;
+ NSData data = (NSData) transferData.data;
+ if (data.length() is 0) return null;
+ NSImage nsImage = (NSImage) new NSImage().alloc();
+ nsImage.initWithData(data);
+ //TODO: Image representation wrong???
+ Image image = Image.cocoa_new(Display.getCurrent(), DWT.BITMAP, nsImage);
+ ImageData imageData = image.getImageData();
+ image.dispose();
+ return imageData;
}
protected int[] getTypeIds() {
- return new int[] { PICTID };
+ return new int[] { TIFFID };
}
protected String[] getTypeNames() {
- return new String[] { PICT };
+ return new String[] { TIFF };
}
bool checkImage(Object object) {
- if (object is null || !( null !is cast(ImageData)object )) return false;
+ if (object is null || !(object instanceof ImageData)) return false;
return true;
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/RTFTransfer.d
--- a/dwt/dnd/RTFTransfer.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/RTFTransfer.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -8,16 +8,17 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.RTFTransfer;
+
+import dwt.dwthelper.utils;
-import dwt.internal.carbon.OS;
-import dwt.internal.carbon.CFRange;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
/**
* The class RTFTransfer
provides a platform specific mechanism
* for converting text in RTF format represented as a java String
- * to a platform specific representation of the data and vice versa. See
- * Transfer
for additional information.
+ * to a platform specific representation of the data and vice versa.
*
* An example of a java String
containing RTF text is shown
* below:
@@ -25,14 +26,16 @@
*
* String rtfData = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i Hello World}";
*
+ *
+ * @see Transfer
*/
-public class RTFTransfer : ByteArrayTransfer {
+public class RTFTransfer extends ByteArrayTransfer {
static RTFTransfer _instance = new RTFTransfer();
- static final String RTF = "RTF "; //$NON-NLS-1$
+ static final String RTF = OS.NSRTFPboardType.getString();
static final int RTFID = registerType(RTF);
-this() {}
+RTFTransfer() {}
/**
* Returns the singleton instance of the RTFTransfer class.
@@ -46,69 +49,34 @@
/**
* This implementation of javaToNative
converts RTF-formatted text
* represented by a java String
to a platform specific representation.
- * For additional information see Transfer#javaToNative
.
*
* @param object a java String
containing RTF text
- * @param transferData an empty TransferData
object; this
- * object will be filled in on return with the platform specific format of the data
+ * @param transferData an empty TransferData
object that will
+ * be filled in on return with the platform specific format of the data
+ *
+ * @see Transfer#nativeToJava
*/
public void javaToNative (Object object, TransferData transferData){
if (!checkRTF(object) || !isSupportedType(transferData)) {
DND.error(DND.ERROR_INVALID_DATA);
}
- transferData.result = -1;
- String String = cast(String)object;
- int count = String.length();
- char[] chars = new char[count];
- String.getChars(0, count, chars, 0);
- int cfString = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, count);
- if (cfString is 0) return;
- try {
- CFRange range = new CFRange();
- range.length = chars.length;
- int encoding = OS.CFStringGetSystemEncoding();
- int[] size = new int[1];
- int numChars = OS.CFStringGetBytes(cfString, range, encoding, cast(byte)'?', true, null, 0, size);
- if (numChars is 0 || size[0] is 0) return;
- byte[] buffer = new byte[size[0]];
- numChars = OS.CFStringGetBytes(cfString, range, encoding, cast(byte)'?', true, buffer, size [0], size);
- if (numChars is 0) return;
- transferData.data = new byte[1][];
- transferData.data[0] = buffer;
- transferData.result = 0;
- } finally {
- OS.CFRelease(cfString);
- }
+ transferData.data = NSString.stringWith((String) object);
}
/**
* This implementation of nativeToJava
converts a platform specific
* representation of RTF text to a java String
.
- * For additional information see Transfer#nativeToJava
.
*
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java String
containing RTF text if the
- * conversion was successful; otherwise null
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java String
containing RTF text if the conversion was successful;
+ * otherwise null
+ *
+ * @see Transfer#javaToNative
*/
public Object nativeToJava(TransferData transferData){
if (!isSupportedType(transferData) || transferData.data is null) return null;
- if (transferData.data.length is 0 || transferData.data[0].length is 0) return null;
- byte[] buffer = transferData.data[0];
- int encoding = OS.CFStringGetSystemEncoding();
- int cfString = OS.CFStringCreateWithBytes(OS.kCFAllocatorDefault, buffer, buffer.length, encoding, true);
- if (cfString is 0) return null;
- try {
- int length = OS.CFStringGetLength(cfString);
- if (length is 0) return null;
- char[] chars = new char[length];
- CFRange range = new CFRange();
- range.length = length;
- OS.CFStringGetCharacters(cfString, range, chars);
- return new String(chars);
- } finally {
- OS.CFRelease(cfString);
- }
+ NSString string = (NSString) transferData.data;
+ return string.getString();
}
protected int[] getTypeIds() {
@@ -120,7 +88,7 @@
}
bool checkRTF(Object object) {
- return (object !is null && null !is cast(String)object && (cast(String)object).length() > 0);
+ return (object !is null && object instanceof String && ((String)object).length() > 0);
}
protected bool validate(Object object) {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/TableDragSourceEffect.d
--- a/dwt/dnd/TableDragSourceEffect.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/TableDragSourceEffect.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 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
@@ -8,9 +8,11 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.TableDragSourceEffect;
-import dwt.widgets.*;
+import dwt.dwthelper.utils;
+
+import dwt.widgets.Table;
/**
* This class provides default implementations to display a source image
@@ -26,17 +28,18 @@
*
* @see DragSourceEffect
* @see DragSourceEvent
+ * @see Sample code and further information
*
* @since 3.3
*/
-public class TableDragSourceEffect : DragSourceEffect {
+public class TableDragSourceEffect extends DragSourceEffect {
/**
* Creates a new TableDragSourceEffect
to handle drag effect
* from the specified Table
.
*
* @param table the Table
that the user clicks on to initiate the drag
*/
- public this(Table table) {
+ public TableDragSourceEffect(Table table) {
super(table);
}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/TableDropTargetEffect.d
--- a/dwt/dnd/TableDropTargetEffect.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/TableDropTargetEffect.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -8,14 +8,14 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.TableDropTargetEffect;
+
+import dwt.dwthelper.utils;
-import dwt.DWT;
-import dwt.graphics.*;
-import dwt.internal.Callback;
-import dwt.internal.carbon.DataBrowserCallbacks;
-import dwt.internal.carbon.OS;
-import dwt.widgets.*;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Table;
+import dwt.widgets.TableItem;
/**
* This class provides a default drag under effect (eg. select, insert and scroll)
@@ -43,37 +43,38 @@
*
* @see DropTargetAdapter
* @see DropTargetEvent
+ * @see Sample code and further information
*
* @since 3.3
*/
-public class TableDropTargetEffect : DropTargetEffect {
+public class TableDropTargetEffect extends DropTargetEffect {
static final int SCROLL_HYSTERESIS = 150; // milli seconds
TableItem scrollItem;
long scrollBeginTime;
- DataBrowserCallbacks callbacks = null;
+// DataBrowserCallbacks callbacks = null;
- static Callback AcceptDragProc;
- static {
- AcceptDragProc = new Callback(TableDropTargetEffect.class, "AcceptDragProc", 5); //$NON-NLS-1$
- int acceptDragProc = AcceptDragProc.getAddress();
- if (acceptDragProc is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
- }
+// static Callback AcceptDragProc;
+// static {
+// AcceptDragProc = new Callback(TableDropTargetEffect.class, "AcceptDragProc", 5); //$NON-NLS-1$
+// int acceptDragProc = AcceptDragProc.getAddress();
+// if (acceptDragProc is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+// }
- static int AcceptDragProc(int theControl, int itemID, int property, int theRect, int theDrag) {
- DropTarget target = FindDropTarget(theControl, theDrag);
- if (target is null) return 0;
- return (target.feedback & DND.FEEDBACK_SELECT) !is 0 ? 1 : 0;
- }
+// static int AcceptDragProc(int theControl, int itemID, int property, int theRect, int theDrag) {
+// DropTarget target = FindDropTarget(theControl, theDrag);
+// if (target is null) return 0;
+// return (target.feedback & DND.FEEDBACK_SELECT) !is 0 ? 1 : 0;
+// }
- static DropTarget FindDropTarget(int theControl, int theDrag) {
- if (theControl is 0) return null;
- Display display = Display.findDisplay(Thread.currentThread());
- if (display is null || display.isDisposed()) return null;
- Widget widget = display.findWidget(theControl);
- if (widget is null) return null;
- return cast(DropTarget)widget.getData(DND.DROP_TARGET_KEY);
- }
+// static DropTarget FindDropTarget(int theControl, int theDrag) {
+// if (theControl is 0) return null;
+// Display display = Display.findDisplay(Thread.currentThread());
+// if (display is null || display.isDisposed()) return null;
+// Widget widget = display.findWidget(theControl);
+// if (widget is null) return null;
+// return (DropTarget)widget.getData(DND.DROP_TARGET_KEY);
+// }
/**
* Creates a new TableDropTargetEffect
to handle the drag under effect on the specified
@@ -81,7 +82,7 @@
*
* @param table the Table
over which the user positions the cursor to drop the data
*/
- public this(Table table) {
+ public TableDropTargetEffect(Table table) {
super(table);
}
@@ -107,13 +108,13 @@
* @see DropTargetEvent
*/
public void dragEnter(DropTargetEvent event) {
- if (callbacks is null) {
- Table table = cast(Table) control;
- DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
- OS.GetDataBrowserCallbacks (table.handle, callbacks);
- callbacks.v1_acceptDragCallback = AcceptDragProc.getAddress();
- OS.SetDataBrowserCallbacks(table.handle, callbacks);
- }
+// if (callbacks is null) {
+// Table table = (Table) control;
+// DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
+// OS.GetDataBrowserCallbacks (table.handle, callbacks);
+// callbacks.v1_acceptDragCallback = AcceptDragProc.getAddress();
+// OS.SetDataBrowserCallbacks(table.handle, callbacks);
+// }
scrollBeginTime = 0;
scrollItem = null;
}
@@ -155,16 +156,16 @@
* @see DND#FEEDBACK_SCROLL
*/
public void dragOver(DropTargetEvent event) {
- Table table = cast(Table) control;
+ Table table = (Table) control;
int effect = checkEffect(event.feedback);
- TableItem item = cast(TableItem)getItem(table, event.x, event.y);
+ TableItem item = (TableItem)getItem(table, event.x, event.y);
if ((effect & DND.FEEDBACK_SCROLL) is 0) {
scrollBeginTime = 0;
scrollItem = null;
} else {
- if (item !is null && item.opEquals(scrollItem) && scrollBeginTime !is 0) {
+ if (item !is null && item.equals(scrollItem) && scrollBeginTime !is 0) {
if (System.currentTimeMillis() >= scrollBeginTime) {
Rectangle area = table.getClientArea();
int headerHeight = table.getHeaderHeight();
@@ -191,6 +192,6 @@
}
// store current effect for selection feedback
- (cast(DropTarget)event.widget).feedback = effect;
+ ((DropTarget)event.widget).feedback = effect;
}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/TextTransfer.d
--- a/dwt/dnd/TextTransfer.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/TextTransfer.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -8,10 +8,12 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.TextTransfer;
-import dwt.internal.carbon.CFRange;
-import dwt.internal.carbon.OS;
+import dwt.dwthelper.utils;
+
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
/**
* The class TextTransfer
provides a platform specific mechanism
@@ -27,15 +29,14 @@
*
* @see Transfer
*/
-public class TextTransfer : ByteArrayTransfer {
+public class TextTransfer extends ByteArrayTransfer {
static TextTransfer _instance = new TextTransfer();
- static final String TEXT = "TEXT"; //$NON-NLS-1$
- static final String UTEXT = "utxt"; //$NON-NLS-1$
- static final int TEXTID = OS.kScrapFlavorTypeText;
- static final int UTEXTID = OS.kScrapFlavorTypeUnicode;
+
+ static final String ID_NAME = OS.NSStringPboardType.getString();
+ static final int ID = registerType(ID_NAME);
-this() {}
+TextTransfer() {}
/**
* Returns the singleton instance of the TextTransfer class.
@@ -51,51 +52,16 @@
* represented by a java String
to a platform specific representation.
*
* @param object a java String
containing text
- * @param transferData an empty TransferData
object; this object
- * will be filled in on return with the platform specific format of the data
+ * @param transferData an empty TransferData
object that will
+ * be filled in on return with the platform specific format of the data
*
- * @see Transfer#javaToNative
+ * @see Transfer#nativeToJava
*/
public void javaToNative (Object object, TransferData transferData) {
if (!checkText(object) || !isSupportedType(transferData)) {
DND.error(DND.ERROR_INVALID_DATA);
}
- String String = cast(String)object;
- char[] chars = new char[String.length()];
- String.getChars (0, chars.length, chars, 0);
- transferData.result = -1;
- switch (transferData.type) {
- case TEXTID: {
- int cfString = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, chars.length);
- if (cfString is 0) return;
- byte[] buffer = null;
- try {
- CFRange range = new CFRange();
- range.length = chars.length;
- int encoding = OS.CFStringGetSystemEncoding();
- int[] size = new int[1];
- int numChars = OS.CFStringGetBytes(cfString, range, encoding, cast(byte)'?', true, null, 0, size);
- if (numChars is 0) return;
- buffer = new byte[size[0]];
- numChars = OS.CFStringGetBytes(cfString, range, encoding, cast(byte)'?', true, buffer, size [0], size);
- if (numChars is 0) return;
- } finally {
- OS.CFRelease(cfString);
- }
- transferData.data = new byte[1][];
- transferData.data[0] = buffer;
- transferData.result = OS.noErr;
- break;
- }
- case UTEXTID: {
- byte[] buffer = new byte[chars.length * 2];
- OS.memmove(buffer, chars, buffer.length);
- transferData.data = new byte[1][];
- transferData.data[0] = buffer;
- transferData.result = OS.noErr;
- break;
- }
- }
+ transferData.data = NSString.stringWith((String) object);
}
/**
@@ -105,48 +71,24 @@
* @param transferData the platform specific representation of the data to be converted
* @return a java String
containing text if the conversion was successful; otherwise null
*
- * @see Transfer#nativeToJava
+ * @see Transfer#javaToNative
*/
public Object nativeToJava(TransferData transferData){
if (!isSupportedType(transferData) || transferData.data is null) return null;
- if (transferData.data.length is 0 || transferData.data[0].length is 0) return null;
- byte[] buffer = transferData.data[0];
- switch (transferData.type) {
- case TEXTID: {
- int encoding = OS.CFStringGetSystemEncoding();
- int cfString = OS.CFStringCreateWithBytes(OS.kCFAllocatorDefault, buffer, buffer.length, encoding, true);
- if (cfString is 0) return null;
- try {
- int length = OS.CFStringGetLength(cfString);
- if (length is 0) return null;
- char[] chars = new char[length];
- CFRange range = new CFRange();
- range.length = length;
- OS.CFStringGetCharacters(cfString, range, chars);
- return new String(chars);
- } finally {
- OS.CFRelease(cfString);
- }
- }
- case UTEXTID: {
- char[] chars = new char[(buffer.length + 1) / 2];
- OS.memmove(chars, buffer, buffer.length);
- return new String(chars);
- }
- }
- return null;
+ NSString string = (NSString) transferData.data;
+ return string.getString();
}
protected int[] getTypeIds() {
- return new int[] {UTEXTID, TEXTID};
+ return new int[] {ID};
}
protected String[] getTypeNames() {
- return new String[] {UTEXT, TEXT};
+ return new String[] {ID_NAME};
}
bool checkText(Object object) {
- return (object !is null && null !is cast(String)object && (cast(String)object).length() > 0);
+ return (object !is null && object instanceof String && ((String)object).length() > 0);
}
protected bool validate(Object object) {
return checkText(object);
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/Transfer.d
--- a/dwt/dnd/Transfer.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/Transfer.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -8,7 +8,9 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.Transfer;
+
+import dwt.dwthelper.utils;
/**
@@ -22,9 +24,14 @@
* ByteArrayTransfer class.
*
* @see ByteArrayTransfer
+ * @see Drag and Drop snippets
+ * @see DWT Example: DNDExample
+ * @see Sample code and further information
*/
public abstract class Transfer {
-
+
+static String[] TYPES = new String[4];
+
/**
* Returns a list of the platform specific data types that can be converted using
* this transfer agent.
@@ -128,15 +135,22 @@
* @return the unique identifier associated with this data type
*/
public static int registerType(String formatName) {
- int length = formatName.length();
- // TODO - hashcode may not be unique - need another way
- if (length > 4) return formatName.toHash();
- int type = 0;
- if (length > 0) type |= (formatName.charAt(0) & 0xff) << 24;
- if (length > 1) type |= (formatName.charAt(1) & 0xff) << 16;
- if (length > 2) type |= (formatName.charAt(2) & 0xff) << 8;
- if (length > 3) type |= formatName.charAt(3) & 0xff;
- return type;
+ /* Note the type 0 is not used */
+ int index = 1;
+ while (index < TYPES.length) {
+ String type = TYPES[index];
+ if (type !is null && formatName.equals(type)) {
+ return index;
+ }
+ index++;
+ }
+ if (index is TYPES.length) {
+ String[] newTypes = new String[TYPES.length + 4];
+ System.arraycopy(TYPES, 0, newTypes, 0, TYPES.length);
+ TYPES = newTypes;
+ }
+ TYPES[index] = formatName;
+ return index;
}
/**
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/TransferData.d
--- a/dwt/dnd/TransferData.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/TransferData.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -8,7 +8,11 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.TransferData;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.cocoa.NSObject;
/**
@@ -24,6 +28,8 @@
* You should only need to become familiar with the fields in this class if you
* are implementing a Transfer subclass and you are unable to subclass the
* ByteArrayTransfer class.
+ *
+ * @see Sample code and further information
*/
public class TransferData {
/**
@@ -32,7 +38,7 @@
*
* IMPORTANT: This field is not part of the DWT
* public API. It is marked public only so that it can be shared
- * within the modules provided by DWT. It is not available on all
+ * within the packages provided by DWT. It is not available on all
* platforms and should never be accessed from application code.
*
*/
@@ -45,25 +51,10 @@
*
* IMPORTANT: This field is not part of the DWT
* public API. It is marked public only so that it can be shared
- * within the modules provided by DWT. It is not available on all
+ * within the packages provided by DWT. It is not available on all
* platforms and should never be accessed from application code.
*
*/
- public byte[][] data;
-
- /**
- * The result field contains the result of converting a
- * java data type into a platform specific value.
- * (Warning: This field is platform dependent)
- *
- * IMPORTANT: This field is not part of the DWT
- * public API. It is marked public only so that it can be shared
- * within the modules provided by DWT. It is not available on all
- * platforms and should never be accessed from application code.
- *
- * The value of result is 1 if the conversion was successful.
- * The value of result is 0 if the conversion failed.
- */
- public int result;
+ public NSObject data;
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/TreeDragSourceEffect.d
--- a/dwt/dnd/TreeDragSourceEffect.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/TreeDragSourceEffect.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 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
@@ -8,9 +8,11 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.TreeDragSourceEffect;
-import dwt.widgets.*;
+import dwt.dwthelper.utils;
+
+import dwt.widgets.Tree;
/**
* This class provides default implementations to display a source image
@@ -25,17 +27,18 @@
*
* @see DragSourceEffect
* @see DragSourceEvent
+ * @see Sample code and further information
*
* @since 3.3
*/
-public class TreeDragSourceEffect : DragSourceEffect {
+public class TreeDragSourceEffect extends DragSourceEffect {
/**
* Creates a new TreeDragSourceEffect
to handle drag effect
* from the specified Tree
.
*
* @param tree the Tree
that the user clicks on to initiate the drag
*/
- public this(Tree tree) {
+ public TreeDragSourceEffect(Tree tree) {
super(tree);
}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/TreeDropTargetEffect.d
--- a/dwt/dnd/TreeDropTargetEffect.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/TreeDropTargetEffect.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -8,14 +8,16 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.TreeDropTargetEffect;
+
+import dwt.dwthelper.utils;
-import dwt.*;
-import dwt.graphics.*;
-import dwt.internal.Callback;
-import dwt.internal.carbon.DataBrowserCallbacks;
-import dwt.internal.carbon.OS;
-import dwt.widgets.*;
+import dwt.DWT;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Event;
+import dwt.widgets.Tree;
+import dwt.widgets.TreeItem;
/**
* This class provides a default drag under effect (eg. select, insert, scroll and expand)
@@ -46,10 +48,11 @@
*
* @see DropTargetAdapter
* @see DropTargetEvent
+ * @see Sample code and further information
*
* @since 3.3
*/
-public class TreeDropTargetEffect : DropTargetEffect {
+public class TreeDropTargetEffect extends DropTargetEffect {
static final int SCROLL_HYSTERESIS = 150; // milli seconds
static final int EXPAND_HYSTERESIS = 1000; // milli seconds
@@ -65,33 +68,33 @@
TreeItem expandItem;
long expandBeginTime;
- DataBrowserCallbacks callbacks = null;
+// DataBrowserCallbacks callbacks = null;
int acceptDragProc(int theControl, int itemID, int property, int theRect, int theDrag) {
return (currentEffect & DND.FEEDBACK_SELECT) !is 0 ? 1 : 0;
}
- static Callback AcceptDragProc;
- static {
- AcceptDragProc = new Callback(TreeDropTargetEffect.class, "AcceptDragProc", 5); //$NON-NLS-1$
- int acceptDragProc = AcceptDragProc.getAddress();
- if (acceptDragProc is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
- }
+// static Callback AcceptDragProc;
+// static {
+// AcceptDragProc = new Callback(TreeDropTargetEffect.class, "AcceptDragProc", 5); //$NON-NLS-1$
+// int acceptDragProc = AcceptDragProc.getAddress();
+// if (acceptDragProc is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+// }
- static int AcceptDragProc(int theControl, int itemID, int property, int theRect, int theDrag) {
- DropTarget target = FindDropTarget(theControl, theDrag);
- if (target is null) return 0;
- return (target.feedback & DND.FEEDBACK_SELECT) !is 0 ? 1 : 0;
- }
+// static int AcceptDragProc(int theControl, int itemID, int property, int theRect, int theDrag) {
+// DropTarget target = FindDropTarget(theControl, theDrag);
+// if (target is null) return 0;
+// return (target.feedback & DND.FEEDBACK_SELECT) !is 0 ? 1 : 0;
+// }
- static DropTarget FindDropTarget(int theControl, int theDrag) {
- if (theControl is 0) return null;
- Display display = Display.findDisplay(Thread.currentThread());
- if (display is null || display.isDisposed()) return null;
- Widget widget = display.findWidget(theControl);
- if (widget is null) return null;
- return cast(DropTarget)widget.getData(DND.DROP_TARGET_KEY);
- }
+// static DropTarget FindDropTarget(int theControl, int theDrag) {
+// if (theControl is 0) return null;
+// Display display = Display.findDisplay(Thread.currentThread());
+// if (display is null || display.isDisposed()) return null;
+// Widget widget = display.findWidget(theControl);
+// if (widget is null) return null;
+// return (DropTarget)widget.getData(DND.DROP_TARGET_KEY);
+// }
/**
* Creates a new TreeDropTargetEffect
to handle the drag under effect on the specified
@@ -99,7 +102,7 @@
*
* @param tree the Tree
over which the user positions the cursor to drop the data
*/
- public this(Tree tree) {
+ public TreeDropTargetEffect(Tree tree) {
super(tree);
}
@@ -125,13 +128,13 @@
* @see DropTargetEvent
*/
public void dragEnter(DropTargetEvent event) {
- if (callbacks is null) {
- Tree table = cast(Tree) control;
- DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
- OS.GetDataBrowserCallbacks (table.handle, callbacks);
- callbacks.v1_acceptDragCallback = AcceptDragProc.getAddress();
- OS.SetDataBrowserCallbacks(table.handle, callbacks);
- }
+// if (callbacks is null) {
+// Tree table = (Tree) control;
+// DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
+// OS.GetDataBrowserCallbacks (table.handle, callbacks);
+// callbacks.v1_acceptDragCallback = AcceptDragProc.getAddress();
+// OS.SetDataBrowserCallbacks(table.handle, callbacks);
+// }
insertItem = null;
expandBeginTime = 0;
expandItem = null;
@@ -154,7 +157,7 @@
* @see DropTargetEvent
*/
public void dragLeave(DropTargetEvent event) {
- Tree tree = cast(Tree) control;
+ Tree tree = (Tree) control;
if (insertItem !is null) {
setInsertMark(tree, null, false);
insertItem = null;
@@ -184,21 +187,21 @@
* @see DND#FEEDBACK_SCROLL
*/
public void dragOver(DropTargetEvent event) {
- Tree tree = cast(Tree) control;
- TreeItem item = cast(TreeItem)getItem(tree, event.x, event.y);
+ Tree tree = (Tree) control;
+ TreeItem item = (TreeItem)getItem(tree, event.x, event.y);
int effect = checkEffect(event.feedback);
if ((effect & DND.FEEDBACK_EXPAND) is 0) {
expandBeginTime = 0;
expandItem = null;
} else {
- if (item !is null && item.opEquals(expandItem) && expandBeginTime !is 0) {
+ if (item !is null && item.equals(expandItem) && expandBeginTime !is 0) {
if (System.currentTimeMillis() >= expandBeginTime) {
if (item.getItemCount() > 0 && !item.getExpanded()) {
Event e = new Event();
e.x = event.x;
e.y = event.y;
e.item = item;
- e.time = cast(int) System.currentTimeMillis();
+ e.time = (int) System.currentTimeMillis();
tree.notifyListeners(DWT.Expand, e);
if (item.isDisposed()) return;
item.setExpanded(true);
@@ -216,7 +219,7 @@
scrollBeginTime = 0;
scrollItem = null;
} else {
- if (item !is null && item.opEquals(scrollItem) && scrollBeginTime !is 0) {
+ if (item !is null && item.equals(scrollItem) && scrollBeginTime !is 0) {
if (System.currentTimeMillis() >= scrollBeginTime) {
Rectangle area = tree.getClientArea();
int headerHeight = tree.getHeaderHeight();
@@ -253,7 +256,7 @@
setInsertMark(tree, null, false);
}
// save current effect for selection feedback
- (cast(DropTarget)event.widget).feedback = effect;
+ ((DropTarget)event.widget).feedback = effect;
}
void setInsertMark(Tree tree, TreeItem item, bool before) {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dnd/URLTransfer.d
--- a/dwt/dnd/URLTransfer.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/URLTransfer.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,1 +1,38 @@
-/*******************************************************************************
* Copyright (c) 20007 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
*******************************************************************************/
module dwt.dnd;
import dwt.internal.carbon.*;
/**
* The class URLTransfer
provides a platform specific mechanism
* for converting text in URL format represented as a java String
* to a platform specific representation of the data and vice versa. See
* Transfer
for additional information. The String
* must contain the fully specified url.
*
* An example of a java String[]
containing a URL is shown
* below:
*
*
* String url = "http://www.eclipse.org";
*
*/
public class URLTransfer : ByteArrayTransfer {
static URLTransfer _instance = new URLTransfer();
static final String URL = "url "; //$NON-NLS-1$
static final int URL_ID = registerType(URL);
static final String URLN = "urln"; //$NON-NLS-1$
static final int URLN_ID = registerType(URLN);
private URLTransfer() {}
/**
* Returns the singleton instance of the URLTransfer class.
*
* @return the singleton instance of the URLTransfer class
*/
public static URLTransfer getInstance () {
return _instance;
}
/**
* This implementation of javaToNative
converts a URL
* represented by a java String
to a platform specific representation.
* For additional information see Transfer#javaToNative
.
*
* @param object a java String[]
containing a URL
* @param transferData an empty TransferData
object; this
* object will be filled in on return with the platform specific format of the data
*/
public void javaToNative (Object object, TransferData transferData){
if (!checkURL(object) || !isSupportedType(transferData)) {
DND.error(DND.ERROR_INVALID_DATA);
}
transferData.result = -1;
String url = cast(String)object;
int count = url.length();
char[] chars = new char[count];
url.getChars(0, count, chars, 0);
int cfString = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, count);
if (cfString is 0) return;
try {
CFRange range = new CFRange();
range.length = chars.length;
int encoding = OS.CFStringGetSystemEncoding();
int[] size = new int[1];
int numChars = OS.CFStringGetBytes(cfString, range, encoding, cast(byte)'?', true, null, 0, size);
if (numChars is 0 || size[0] is 0) return;
byte[] buffer = new byte[size[0]];
numChars = OS.CFStringGetBytes(cfString, range, encoding, cast(byte)'?', true, buffer, size [0], size);
if (numChars is 0) return;
transferData.data = new byte[][] {buffer};
transferData.result = 0;
} finally {
OS.CFRelease(cfString);
}
}
/**
* This implementation of nativeToJava
converts a platform specific
* representation of a URL to a java String
.
* For additional information see Transfer#nativeToJava
.
*
* @param transferData the platform specific representation of the data to be
* converted
* @return a java String[]
containing a URL if the
* conversion was successful; otherwise null
*/
public Object nativeToJava(TransferData transferData){
if (!isSupportedType(transferData) || transferData.data is null) return null;
if (transferData.data.length is 0) return null;
byte[] buffer = transferData.data[0];
int encoding = OS.CFStringGetSystemEncoding();
int cfString = OS.CFStringCreateWithBytes(OS.kCFAllocatorDefault, buffer, buffer.length, encoding, true);
if (cfString is 0) return null;
try {
int length = OS.CFStringGetLength(cfString);
if (length is 0) return null;
char[] chars = new char[length];
CFRange range = new CFRange();
range.length = length;
OS.CFStringGetCharacters(cfString, range, chars);
return new String(chars);
} finally {
OS.CFRelease(cfString);
}
}
protected int[] getTypeIds(){
return new int[] {URL_ID, URLN_ID};
}
protected String[] getTypeNames(){
return new String[] {URL, URLN};
}
bool checkURL(Object object) {
return object !is null && ( null !is cast(String)object ) && (cast(String)object).length() > 0;
}
protected bool validate(Object object) {
return checkURL(object);
}
}
+/*******************************************************************************
* Copyright (c) 20007 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
*******************************************************************************/
module dwt.dnd;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSURL;
import dwt.internal.cocoa.OS.URLTransfer;
/**
+
+import dwt.dwthelper.utils;
+ * The class URLTransfer
provides a platform specific mechanism
+ * for converting text in URL format represented as a java String
+ * to a platform specific representation of the data and vice versa. The string
+ * must contain a fully specified url.
+ *
+ * An example of a java String
containing a URL is shown below:
+ *
+ *
+ * String url = "http://www.eclipse.org";
+ *
+ *
+ * @see Transfer
+ */
public class URLTransfer extends ByteArrayTransfer {
static URLTransfer _instance = new URLTransfer();
static final String URL = OS.NSURLPboardType.getString();
static final int URL_ID = registerType(URL);
private URLTransfer() {}
/**
+ * Returns the singleton instance of the URLTransfer class.
+ *
+ * @return the singleton instance of the URLTransfer class
+ */
public static URLTransfer getInstance () {
return _instance;
}
/**
+ * This implementation of javaToNative
converts a URL
+ * represented by a java String
to a platform specific representation.
+ *
+ * @param object a java String
containing a URL
+ * @param transferData an empty TransferData
object that will
+ * be filled in on return with the platform specific format of the data
+ *
+ * @see Transfer#nativeToJava
+ */
public void javaToNative (Object object, TransferData transferData){
if (!checkURL(object) || !isSupportedType(transferData)) {
DND.error(DND.ERROR_INVALID_DATA);
}
String url = (String)object;
NSString nsString = NSString.stringWith(url);
NSString escapedString = nsString.stringByAddingPercentEscapesUsingEncoding(OS.NSUTF8StringEncoding);
transferData.data = NSURL.URLWithString(escapedString);
}
/**
+ * This implementation of nativeToJava
converts a platform
+ * specific representation of a URL to a java String
.
+ *
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java String
containing a URL if the conversion was successful;
+ * otherwise null
+ *
+ * @see Transfer#javaToNative
+ */
public Object nativeToJava(TransferData transferData){
if (!isSupportedType(transferData) || transferData.data is null) return null;
NSURL nsUrl = (NSURL) transferData.data;
NSString nsString = nsUrl.absoluteString();
return nsString.getString();
}
protected int[] getTypeIds(){
return new int[] {URL_ID};
}
protected String[] getTypeNames(){
return new String[] {URL};
}
bool checkURL(Object object) {
return object !is null && (object instanceof String) && ((String)object).length() > 0;
}
protected bool validate(Object object) {
return checkURL(object);
}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/BufferedInputStream.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/ByteArrayInputStream.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/ByteArrayOutputStream.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/File.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/FileInputStream.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/FileOutputStream.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/InflaterInputStream.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/InputStream.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/OutputStream.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/ResourceBundle.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/Runnable.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/System.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/WeakHashMap.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/WeakRef.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/XmlTranscode.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/dwthelper/utils.d
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ArmEvent.d
--- a/dwt/events/ArmEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ArmEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ArmListener.d
--- a/dwt/events/ArmListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ArmListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
@@ -15,6 +15,7 @@
public import dwt.internal.DWTEventListener;
public import dwt.events.ArmEvent;
+
/**
* Classes which implement this interface provide a method
* that deals with the event that is generated when a widget,
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ControlAdapter.d
--- a/dwt/events/ControlAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ControlAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ControlEvent.d
--- a/dwt/events/ControlEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ControlEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ControlListener.d
--- a/dwt/events/ControlListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ControlListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
@@ -15,6 +15,7 @@
public import dwt.internal.DWTEventListener;
public import dwt.events.ControlEvent;
+
/**
* Classes which implement this interface provide methods
* that deal with the events that are generated by moving
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/DisposeEvent.d
--- a/dwt/events/DisposeEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/DisposeEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/DisposeListener.d
--- a/dwt/events/DisposeListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/DisposeListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/DragDetectEvent.d
--- a/dwt/events/DragDetectEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/DragDetectEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/DragDetectListener.d
--- a/dwt/events/DragDetectListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/DragDetectListener.d Mon Dec 01 17:07:00 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ExpandAdapter.d
--- a/dwt/events/ExpandAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ExpandAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ExpandEvent.d
--- a/dwt/events/ExpandEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ExpandEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ExpandListener.d
--- a/dwt/events/ExpandListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ExpandListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2006 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/FocusAdapter.d
--- a/dwt/events/FocusAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/FocusAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/FocusEvent.d
--- a/dwt/events/FocusEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/FocusEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/FocusListener.d
--- a/dwt/events/FocusListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/FocusListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/HelpEvent.d
--- a/dwt/events/HelpEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/HelpEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/HelpListener.d
--- a/dwt/events/HelpListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/HelpListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/KeyAdapter.d
--- a/dwt/events/KeyAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/KeyAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/KeyEvent.d
--- a/dwt/events/KeyEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/KeyEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/KeyListener.d
--- a/dwt/events/KeyListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/KeyListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/MenuAdapter.d
--- a/dwt/events/MenuAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/MenuAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/MenuDetectEvent.d
--- a/dwt/events/MenuDetectEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/MenuDetectEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/MenuDetectListener.d
--- a/dwt/events/MenuDetectListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/MenuDetectListener.d Mon Dec 01 17:07:00 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/MenuEvent.d
--- a/dwt/events/MenuEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/MenuEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/MenuListener.d
--- a/dwt/events/MenuListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/MenuListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2005 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ModifyEvent.d
--- a/dwt/events/ModifyEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ModifyEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ModifyListener.d
--- a/dwt/events/ModifyListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ModifyListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/MouseAdapter.d
--- a/dwt/events/MouseAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/MouseAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/MouseEvent.d
--- a/dwt/events/MouseEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/MouseEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/MouseListener.d
--- a/dwt/events/MouseListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/MouseListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2004 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/MouseMoveListener.d
--- a/dwt/events/MouseMoveListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/MouseMoveListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/MouseTrackAdapter.d
--- a/dwt/events/MouseTrackAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/MouseTrackAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/MouseTrackListener.d
--- a/dwt/events/MouseTrackListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/MouseTrackListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/MouseWheelListener.d
--- a/dwt/events/MouseWheelListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/MouseWheelListener.d Mon Dec 01 17:07:00 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/PaintEvent.d
--- a/dwt/events/PaintEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/PaintEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/PaintListener.d
--- a/dwt/events/PaintListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/PaintListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/SelectionAdapter.d
--- a/dwt/events/SelectionAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/SelectionAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/SelectionEvent.d
--- a/dwt/events/SelectionEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/SelectionEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/SelectionListener.d
--- a/dwt/events/SelectionListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/SelectionListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2005 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ShellAdapter.d
--- a/dwt/events/ShellAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ShellAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ShellEvent.d
--- a/dwt/events/ShellEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ShellEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/ShellListener.d
--- a/dwt/events/ShellListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/ShellListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2005 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/TraverseEvent.d
--- a/dwt/events/TraverseEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/TraverseEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/TraverseListener.d
--- a/dwt/events/TraverseListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/TraverseListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/TreeAdapter.d
--- a/dwt/events/TreeAdapter.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/TreeAdapter.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/TreeEvent.d
--- a/dwt/events/TreeEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/TreeEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/TypedEvent.d
--- a/dwt/events/TypedEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/TypedEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/VerifyEvent.d
--- a/dwt/events/VerifyEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/VerifyEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/events/VerifyListener.d
--- a/dwt/events/VerifyListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/events/VerifyListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2005 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Color.d
--- a/dwt/graphics/Color.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Color.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Color;
@@ -38,6 +38,9 @@
*
* @see RGB
* @see Device#getSystemColor
+ * @see Color and RGB snippets
+ * @see DWT Example: PaintExample
+ * @see Sample code and further information
*/
public final class Color : Resource {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Cursor.d
--- a/dwt/graphics/Cursor.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Cursor.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,19 +9,21 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Cursor;
import dwt.DWT;
import dwt.DWTError;
+import dwt.internal.cocoa.NSAutoreleasePool;
import dwt.internal.cocoa.NSBitmapImageRep;
import dwt.internal.cocoa.NSCursor;
import dwt.internal.cocoa.NSImage;
import dwt.internal.cocoa.NSPoint;
import dwt.internal.cocoa.NSSize;
import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSThread;
import dwt.internal.cocoa.OS;
import tango.text.convert.Format;
@@ -57,11 +59,32 @@
*
* Note: Only one of the above styles may be specified.
*
+ *
+ * @see Cursor snippets
+ * @see Sample code and further information
*/
public final class Cursor : Resource {
alias Resource.init_ init_;
+ static final byte[] WAIT_SOURCE = new byte[] {
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ };
/**
* the handle to the OS cursor resource
@@ -125,35 +148,62 @@
*/
public this(Device device, int style) {
super(device);
- switch (style) {
- case DWT.CURSOR_HAND: handle = NSCursor.pointingHandCursor(); break;
- case DWT.CURSOR_ARROW: handle = NSCursor.arrowCursor(); break;
- case DWT.CURSOR_WAIT: handle = NSCursor.crosshairCursor(); break;
- case DWT.CURSOR_CROSS: handle = NSCursor.crosshairCursor(); break;
- case DWT.CURSOR_APPSTARTING: handle = NSCursor.arrowCursor(); break;
- case DWT.CURSOR_HELP: handle = NSCursor.crosshairCursor(); break;
- case DWT.CURSOR_SIZEALL: handle = NSCursor.crosshairCursor(); break;
- case DWT.CURSOR_SIZENESW: handle = NSCursor.crosshairCursor(); break;
- case DWT.CURSOR_SIZENS: handle = NSCursor.resizeUpDownCursor(); break;
- case DWT.CURSOR_SIZENWSE: handle = NSCursor.crosshairCursor(); break;
- case DWT.CURSOR_SIZEWE: handle = NSCursor.resizeLeftRightCursor(); break;
- case DWT.CURSOR_SIZEN: handle = NSCursor.resizeUpCursor(); break;
- case DWT.CURSOR_SIZES: handle = NSCursor.resizeDownCursor(); break;
- case DWT.CURSOR_SIZEE: handle = NSCursor.resizeRightCursor(); break;
- case DWT.CURSOR_SIZEW: handle = NSCursor.resizeLeftCursor(); break;
- case DWT.CURSOR_SIZENE: handle = NSCursor.crosshairCursor(); break;
- case DWT.CURSOR_SIZESE: handle = NSCursor.crosshairCursor(); break;
- case DWT.CURSOR_SIZESW: handle = NSCursor.crosshairCursor(); break;
- case DWT.CURSOR_SIZENW: handle = NSCursor.crosshairCursor(); break;
- case DWT.CURSOR_UPARROW: handle = NSCursor.crosshairCursor(); break;
- case DWT.CURSOR_IBEAM: handle = NSCursor.IBeamCursor(); break;
- case DWT.CURSOR_NO: handle = NSCursor.crosshairCursor(); break;
- default:
- DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ switch (style) {
+ case DWT.CURSOR_HAND: handle = NSCursor.pointingHandCursor(); break;
+ case DWT.CURSOR_ARROW: handle = NSCursor.arrowCursor(); break;
+ case DWT.CURSOR_WAIT: break;
+ case DWT.CURSOR_CROSS: handle = NSCursor.crosshairCursor(); break;
+ case DWT.CURSOR_APPSTARTING: handle = NSCursor.arrowCursor(); break;
+ case DWT.CURSOR_HELP: handle = NSCursor.crosshairCursor(); break;
+ case DWT.CURSOR_SIZEALL: handle = NSCursor.crosshairCursor(); break;
+ case DWT.CURSOR_SIZENESW: handle = NSCursor.crosshairCursor(); break;
+ case DWT.CURSOR_SIZENS: handle = NSCursor.resizeUpDownCursor(); break;
+ case DWT.CURSOR_SIZENWSE: handle = NSCursor.crosshairCursor(); break;
+ case DWT.CURSOR_SIZEWE: handle = NSCursor.resizeLeftRightCursor(); break;
+ case DWT.CURSOR_SIZEN: handle = NSCursor.resizeUpCursor(); break;
+ case DWT.CURSOR_SIZES: handle = NSCursor.resizeDownCursor(); break;
+ case DWT.CURSOR_SIZEE: handle = NSCursor.resizeRightCursor(); break;
+ case DWT.CURSOR_SIZEW: handle = NSCursor.resizeLeftCursor(); break;
+ case DWT.CURSOR_SIZENE: handle = NSCursor.crosshairCursor(); break;
+ case DWT.CURSOR_SIZESE: handle = NSCursor.crosshairCursor(); break;
+ case DWT.CURSOR_SIZESW: handle = NSCursor.crosshairCursor(); break;
+ case DWT.CURSOR_SIZENW: handle = NSCursor.crosshairCursor(); break;
+ case DWT.CURSOR_UPARROW: handle = NSCursor.crosshairCursor(); break;
+ case DWT.CURSOR_IBEAM: handle = NSCursor.IBeamCursor(); break;
+ case DWT.CURSOR_NO: handle = NSCursor.crosshairCursor(); break;
+ default:
+ DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (handle is null && style is DWT.CURSOR_WAIT) {
+ NSImage nsImage = (NSImage)new NSImage().alloc();
+ NSBitmapImageRep nsImageRep = (NSBitmapImageRep)new NSBitmapImageRep().alloc();
+ handle = (NSCursor)new NSCursor().alloc();
+ int width = 16, height = 16;
+ NSSize size = new NSSize();
+ size.width = width;
+ size.height = height;
+ nsImage = nsImage.initWithSize(size);
+ nsImageRep = nsImageRep.initWithBitmapDataPlanes(0, width, height, 8, 4, true, false, OS.NSDeviceRGBColorSpace,
+ OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, width*4, 32);
+ OS.memmove(nsImageRep.bitmapData(), WAIT_SOURCE, WAIT_SOURCE.length);
+ nsImage.addRepresentation(nsImageRep);
+ NSPoint point = new NSPoint();
+ point.x = 0;
+ point.y = 0;
+ handle = handle.initWithImage(nsImage, point);
+ nsImageRep.release();
+ nsImage.release();
+ } else {
+ handle.retain();
+ }
+ handle.setOnMouseEntered(true);
+ init_();
+ } finally {
+ if (pool !is null) pool.release();
}
- handle.retain();
- handle.setOnMouseEntered(true);
- init_();
}
/**
@@ -230,8 +280,14 @@
offset += 4;
}
}
- createNSCursor(hotspotX, hotspotY, data, source.width, source.height);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ createNSCursor(hotspotX, hotspotY, data, source.width, source.height);
init_();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
void createNSCursor(int hotspotX, int hotspotY, byte[] buffer, int width, int height) {
@@ -243,7 +299,7 @@
size.width = width;
size.height = height;
nsImage = nsImage.initWithSize(size);
- nsImageRep = nsImageRep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(dummy, cast(NSInteger) width, cast(NSInteger) height,
+ nsImageRep = nsImageRep.initWithBitmapDataPlanes(0, width, height,
8, 4, true, false, OS.NSDeviceRGBColorSpace,
NSAlphaFirstBitmapFormat | NSAlphaNonpremultipliedBitmapFormat, cast(NSInteger) (width * 4), 32);
OS.memmove(cast(void*) nsImageRep.bitmapData(), buffer.ptr, buffer.length);
@@ -251,7 +307,7 @@
NSPoint point = NSPoint();
point.x = hotspotX;
point.y = hotspotY;
- handle = handle.initWithImage_hotSpot_(nsImage, point);
+ handle = handle.initWithImage(nsImage, point);
nsImageRep.release();
nsImage.release();
}
@@ -340,8 +396,14 @@
data[i] = alphaData[i/4];
}
}
- createNSCursor(hotspotX, hotspotY, data, source.width, source.height);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ createNSCursor(hotspotX, hotspotY, data, source.width, source.height);
init_();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
void destroy() {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Device.d
--- a/dwt/graphics/Device.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Device.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Device;
@@ -17,13 +17,17 @@
import dwt.DWTException;
import dwt.internal.Compatibility;
import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSAutoreleasePool;
import dwt.internal.cocoa.NSDictionary;
import dwt.internal.cocoa.NSFont;
import dwt.internal.cocoa.NSFontManager;
+import dwt.internal.cocoa.NSMutableDictionary;
+import dwt.internal.cocoa.NSNumber;
import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSScreen;
import dwt.internal.cocoa.NSSize;
import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSThread;
import dwt.internal.cocoa.NSValue;
import dwt.internal.cocoa.OS;
import dwt.internal.cocoa.id;
@@ -47,6 +51,8 @@
* such as the Display device and the Printer device. Devices
* can have a graphics context cast(GC) created for them, and they
* can be drawn on by sending messages to the associated GC.
+ *
+ * @see Sample code and further information
*/
public abstract class Device : Drawable {
@@ -67,7 +73,10 @@
/* System Font */
Font systemFont;
-
+
+ /* Device DPI */
+ Point dpi;
+
/*
* TEMPORARY CODE. When a graphics object is
* created and the device parameter is null,
@@ -136,6 +145,18 @@
objects = new Object [128];
trackingLock = new Object ();
}
+ NSAutoreleasePool pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ NSThread nsthread = NSThread.currentThread();
+ NSMutableDictionary dictionary = nsthread.threadDictionary();
+ NSString key = NSString.stringWith("DWT_NSAutoreleasePool");
+ id obj = dictionary.objectForKey(key);
+ if (obj is null) {
+ NSNumber nsnumber = NSNumber.numberWithInteger(pool.id);
+ dictionary.setObject(nsnumber, key);
+ } else {
+ pool.release();
+ }
+ //check and create pool
create (data);
init_ ();
}
@@ -249,9 +270,8 @@
*/
public Rectangle getBounds () {
checkDevice ();
- NSScreen screen = NSScreen.mainScreen();
- NSRect rect = screen.frame();
- return new Rectangle(cast(int)rect.x, cast(int)rect.y, cast(int)rect.width, cast(int)rect.height);
+ NSRect frame = getPrimaryScreen().frame();
+ return new Rectangle(cast(int)frame.x, cast(int)frame.y, cast(int)frame.width, cast(int)frame.height);
}
/**
@@ -310,9 +330,7 @@
*/
public Rectangle getClientArea () {
checkDevice ();
- NSScreen screen = NSScreen.mainScreen();
- NSRect rect = screen.visibleFrame();
- return new Rectangle(cast(int)rect.x, cast(int)rect.y, cast(int)rect.width, cast(int)rect.height);
+ return getBounds ();
}
/**
@@ -329,7 +347,7 @@
*/
public int getDepth () {
checkDevice ();
- return OS.NSBitsPerPixelFromDepth(NSScreen.mainScreen().depth());
+ return (int)/*64*/OS.NSBitsPerPixelFromDepth(getPrimaryScreen().depth());
}
/**
@@ -345,10 +363,12 @@
*/
public Point getDPI () {
checkDevice ();
- NSDictionary dictionary = NSScreen.mainScreen().deviceDescription();
- NSValue value = new NSValue(dictionary.objectForKey(new id(OS.NSDeviceResolution())).id_);
- NSSize size = value.sizeValue();
- return new Point(cast(int)size.width, cast(int)size.height);
+ return getScreenDPI();
+}
+
+NSScreen getPrimaryScreen () {
+ NSArray screens = NSScreen.screens();
+ return new NSScreen(screens.objectAtIndex(0));
}
/**
@@ -367,24 +387,35 @@
public FontData[] getFontList (String faceName, bool scalable) {
checkDevice ();
if (!scalable) return new FontData[0];
- NSArray fonts = NSFontManager.sharedFontManager().availableFonts();
- int count = 0;
- FontData[] fds = new FontData[fonts.count()];
- for (NSUInteger i = 0; i < fds.length; i++) {
- NSString str = new NSString(fonts.objectAtIndex(i));
- char[] buffer = new char[str.length()];
- str.getCharacters_(buffer.toString16().ptr);
- String nsName = buffer.dup;
- String name = nsName;
- int index = nsName.indexOf('-');
- if (index !is -1) name = name.substring(0, index);
- int style = DWT.NORMAL;
- if (nsName.indexOf("Italic") !is -1) style |= DWT.ITALIC;
- if (nsName.indexOf("Bold") !is -1) style |= DWT.BOLD;
- if (faceName is null || Compatibility.equalsIgnoreCase(faceName, name)) {
- FontData data = new FontData(name, 0, style);
- data.nsName = nsName;
- fds[count++] = data;
+ NSArray families = NSFontManager.sharedFontManager().availableFontFamilies();
+ int famCount = families.count();
+ int count = 0;
+ FontData[] fds = new FontData[100];
+ for (int i = 0; i < famCount; i++) {
+ NSString nsfamily = new NSString(families.objectAtIndex(i));
+ String family = nsfamily.getString();
+ NSArray fonts = NSFontManager.sharedFontManager().availableMembersOfFontFamily(nsfamily);
+ int fontCount = fonts.count();
+ for (int j = 0; j < fontCount; j++) {
+ NSArray fontDetails = new NSArray(fonts.objectAtIndex(j));
+ NSString str = new NSString(fontDetails.objectAtIndex(0));
+ String nsName = str.getString();
+ String name = nsName;
+ int index = nsName.indexOf('-');
+ if (index !is -1) name = name.substring(0, index);
+ int style = DWT.NORMAL;
+ if (nsName.indexOf("Italic") !is -1) style |= DWT.ITALIC;
+ if (nsName.indexOf("Bold") !is -1) style |= DWT.BOLD;
+ if (faceName is null || Compatibility.equalsIgnoreCase(faceName, name)) {
+ FontData data = new FontData(family, 0, style);
+ data.nsName = nsName;
+ if (count is fds.length) {
+ FontData[] newFds = new FontData[fds.length + 100];
+ System.arraycopy(fds, 0, newFds, 0, fds.length);
+ fds = newFds;
+ }
+ fds[count++] = data;
+ }
}
}
if (count is fds.length) return fds;
@@ -393,6 +424,13 @@
return result;
}
+Point getScreenDPI () {
+ NSDictionary dictionary = getPrimaryScreen().deviceDescription();
+ NSValue value = new NSValue(dictionary.objectForKey(new id(OS.NSDeviceResolution())).id);
+ NSSize size = value.sizeValue();
+ return new Point((int)size.width, (int)size.height);
+}
+
/**
* Returns the matching standard color for the given
* constant, which should be one of the color constants
@@ -507,7 +545,10 @@
COLOR_WHITE = new Color (this, 0xFF,0xFF,0xFF);
/* Initialize the system font slot */
- NSFont font = NSFont.systemFontOfSize(NSFont.systemFontSize());
+ bool smallFonts = System.getProperty("dwt.internal.carbon.smallFonts") !is null;
+ float systemFontSize = smallFonts ? NSFont.smallSystemFontSize() : NSFont.systemFontSize();
+ Point dpi = this.dpi = getDPI(), screenDPI = getScreenDPI();
+ NSFont font = NSFont.systemFontOfSize(systemFontSize * dpi.y / screenDPI.y);
systemFont = Font.cocoa_new(this, font);
}
@@ -579,6 +620,7 @@
bool result = false;
char [] chars = new char [path.length ()];
path.getChars (0, chars.length, chars, 0);
+ //TODO not done
return result;
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/DeviceData.d
--- a/dwt/graphics/DeviceData.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/DeviceData.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
+/*******************************************************************************
+ * 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
* which accompanies this distribution, and is available at
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.DeviceData;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Drawable.d
--- a/dwt/graphics/Drawable.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Drawable.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Drawable;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Font.d
--- a/dwt/graphics/Font.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Font.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Font;
@@ -17,8 +17,10 @@
import dwt.DWT;
import dwt.DWTError;
import dwt.DWTException;
+import dwt.internal.cocoa.NSAutoreleasePool;
import dwt.internal.cocoa.NSFont;
import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSThread;
import tango.stdc.stringz;
import tango.text.convert.Format;
@@ -42,6 +44,9 @@
*
*
* @see FontData
+ * @see Font snippets
+ * @see DWT Examples: GraphicsExample, PaintExample
+ * @see Sample code and further information
*/
public final class Font : Resource {
@@ -84,8 +89,14 @@
public this(Device device, FontData fd) {
super(device);
if (fd is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- init_(fd.getName(), fd.getHeightF(), fd.getStyle(), fd.nsName);
- init_();
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ init(fd.getName(), fd.getHeightF(), fd.getStyle(), fd.nsName);
+ init();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -118,9 +129,15 @@
for (int i=0; i
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.FontData;
@@ -41,6 +41,7 @@
* required, and thus no dispose()
method is provided.
*
* @see Font
+ * @see Sample code and further information
*/
public final class FontData {
/**
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/FontMetrics.d
--- a/dwt/graphics/FontMetrics.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/FontMetrics.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.FontMetrics;
@@ -24,6 +24,7 @@
* using the getFontMetrics()
method.
*
* @see GC#getFontMetrics
+ * @see Sample code and further information
*/
public final class FontMetrics {
int ascent, descent, averageCharWidth, leading, height;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/GC.d
--- a/dwt/graphics/GC.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/GC.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.GC;
@@ -19,7 +19,9 @@
import dwt.DWTException;
import dwt.internal.cocoa.NSAffineTransform;
import dwt.internal.cocoa.NSAffineTransformStruct;
+import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSAutoreleasePool;
import dwt.internal.cocoa.NSBezierPath;
import dwt.internal.cocoa.NSColor;
import dwt.internal.cocoa.NSFont;
@@ -28,10 +30,13 @@
import dwt.internal.cocoa.NSImage;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSMutableDictionary;
+import dwt.internal.cocoa.NSMutableParagraphStyle;
import dwt.internal.cocoa.NSPoint;
import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSSize;
import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSThread;
+import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
import tango.text.convert.Format;
@@ -85,6 +90,9 @@
*
*
* @see dwt.events.PaintEvent
+ * @see GC snippets
+ * @see DWT Examples: GraphicsExample, PaintExample
+ * @see Sample code and further information
*/
public final class GC : Resource {
@@ -230,41 +238,46 @@
return gc;
}
-/**
- * Invokes platform specific functionality to wrap a graphics context.
- *
- * IMPORTANT: This method is not part of the public
- * API for GC
. It is marked public only so that it
- * can be shared within the packages provided by DWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- *
- *
- * @param context the Quartz context.
- * @param data the data for the receiver.
- *
- * @return a new GC
- */
-public static GC carbon_new(objc.id context, GCData data) {
- GC gc = new GC();
- gc.device = data.device;
- gc.init_(null, data, context);
- return gc;
-}
-
-void checkGC (int mask) {
- if ((data.state & CLIPPING) is 0 || (data.state & TRANSFORM) is 0) {
- handle.restoreGraphicsState();
- handle.saveGraphicsState();
- if (data.clipPath !is null) data.clipPath.addClip();
- if (data.transform !is null) data.transform.concat();
- mask &= ~(TRANSFORM | CLIPPING);
- data.state |= TRANSFORM | CLIPPING;
- data.state &= ~(BACKGROUND | FOREGROUND);
+NSAutoreleasePool checkGC (int mask) {
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ if ((mask & (CLIPPING | TRANSFORM)) !is 0) {
+ NSGraphicsContext.setCurrentContext(handle);
+ NSView view = data.view;
+ if (view !is null && data.paintRect is null) {
+ NSRect rect = view.convertRect_toView_(view.bounds(), null);
+ NSRect visibleRect = view.visibleRect();
+ if (data.windowRect is null || rect.x !is data.windowRect.x || rect.y !is data.windowRect.y ||
+ rect.width !is data.windowRect.width || rect.height !is data.windowRect.height ||
+ visibleRect.x !is data.visibleRect.x || visibleRect.y !is data.visibleRect.y ||
+ visibleRect.width !is data.visibleRect.width || visibleRect.height !is data.visibleRect.height)
+ {
+ data.state &= ~CLIPPING;
+ data.windowRect = rect;
+ data.visibleRect = visibleRect;
+ }
+ }
+ if ((data.state & CLIPPING) is 0 || (data.state & TRANSFORM) is 0) {
+ handle.restoreGraphicsState();
+ handle.saveGraphicsState();
+ if (view !is null && data.paintRect is null) {
+ NSAffineTransform transform = NSAffineTransform.transform();
+ NSRect rect = data.windowRect;
+ transform.translateXBy(rect.x, rect.y + rect.height);
+ transform.scaleXBy(1, -1);
+ transform.concat();
+ NSBezierPath.bezierPathWithRect(data.visibleRect).addClip();
+ }
+ if (data.clipPath !is null) data.clipPath.addClip();
+ if (data.transform !is null) data.transform.concat();
+ mask &= ~(TRANSFORM | CLIPPING);
+ data.state |= TRANSFORM | CLIPPING;
+ data.state &= ~(BACKGROUND | FOREGROUND);
+ }
}
int state = data.state;
- if ((state & mask) is mask) return;
+ if ((state & mask) is mask) return pool;
state = (state ^ mask) & mask;
data.state |= mask;
@@ -370,6 +383,7 @@
data.drawYOffset = 0.5f / scaling;
}
}
+ return pool;
}
/**
@@ -646,53 +660,61 @@
NSMutableDictionary dict = NSMutableDictionary.dictionaryWithCapacity(4);
CGFloat[] foreground = data.foreground;
NSColor color = NSColor.colorWithDeviceRed(foreground[0], foreground[1], foreground[2], data.alpha / 255f);
- dict.setObject(color, OS.NSForegroundColorAttributeName());
- dict.setObject(data.font.handle, OS.NSFontAttributeName());
+ dict.setObject(color, OS.NSForegroundColorAttributeName);
+ dict.setObject(data.font.handle, OS.NSFontAttributeName);
if ((flags & DWT.DRAW_TRANSPARENT) is 0) {
CGFloat[] background = data.background;
color = NSColor.colorWithDeviceRed(background[0], background[1], background[2], data.alpha / 255f);
dict.setObject(color, OS.FuncNSBackgroundColorAttributeName());
}
+ if ((flags & DWT.DRAW_TAB) is 0) {
+ NSMutableParagraphStyle paragraph = (NSMutableParagraphStyle)new NSMutableParagraphStyle().alloc().init();
+ paragraph.setAlignment(OS.NSLeftTextAlignment);
+ paragraph.setLineBreakMode(OS.NSLineBreakByClipping);
+ paragraph.setTabStops(NSArray.array());
+ dict.setObject(paragraph, OS.NSParagraphStyleAttributeName);
+ paragraph.release();
+ }
size_t length = string.length();
char[] chars = new char[length];
string.getChars(0, length, chars, 0);
-// int breakCount = 0;
-// int[] breaks = null;
-// if ((flags & (DWT.DRAW_MNEMONIC | DWT.DRAW_DELIMITER)) !is 0) {
-// int i=0, j=0;
-// while (i < chars.length) {
-// char c = chars [j++] = chars [i++];
-// switch (c) {
-// case '&': {
-// if ((flags & DWT.DRAW_MNEMONIC) !is 0) {
-// if (i is chars.length) {continue;}
-// if (chars [i] is '&') {i++; continue;}
-// j--;
-// }
-// break;
-// }
-// case '\r':
-// case '\n': {
-// if ((flags & DWT.DRAW_DELIMITER) !is 0) {
-// if (c is '\r' && i !is chars.length && chars[i] is '\n') i++;
-// j--;
-// if (breaks is null) {
-// breaks = new int[4];
-// } else if (breakCount is breaks.length) {
-// int[] newBreaks = new int[breaks.length + 4];
-// System.arraycopy(breaks, 0, newBreaks, 0, breaks.length);
-// breaks = newBreaks;
-// }
-// breaks[breakCount++] = j;
-// }
-// break;
-// }
-// }
-// }
-// length = j;
-// }
+ int breakCount = 0;
+ int[] breaks = null;
+ if ((flags & DWT.DRAW_MNEMONIC) !is 0 || (flags & DWT.DRAW_DELIMITER) is 0) {
+ int i=0, j=0;
+ while (i < chars.length) {
+ char c = chars [j++] = chars [i++];
+ switch (c) {
+ case '&': {
+ if ((flags & DWT.DRAW_MNEMONIC) !is 0) {
+ if (i is chars.length) {continue;}
+ if (chars [i] is '&') {i++; continue;}
+ j--;
+ }
+ break;
+ }
+ case '\r':
+ case '\n': {
+ if ((flags & DWT.DRAW_DELIMITER) is 0) {
+ if (c is '\r' && i !is chars.length && chars[i] is '\n') i++;
+ j--;
+ if (breaks is null) {
+ breaks = new int[4];
+ } else if (breakCount is breaks.length) {
+ int[] newBreaks = new int[breaks.length + 4];
+ System.arraycopy(breaks, 0, newBreaks, 0, breaks.length);
+ breaks = newBreaks;
+ }
+ breaks[breakCount++] = j;
+ }
+ break;
+ }
+ }
+ }
+ length = j;
+ }
NSString str = NSString.stringWithCharacters(chars.toCharArray().ptr, length);
- return (cast(NSAttributedString)(new NSAttributedString()).alloc()).initWithString_attributes_(str, dict);
+ return (cast(NSAttributedString)(new NSAttributedString()).alloc()).initWithString(str, dict);
}
void destroy() {
@@ -702,6 +724,7 @@
image.memGC = null;
image.createAlpha();
}
+ if (data.path !is null) data.path.release();
if (data.clipPath !is null) data.clipPath.release();
if (data.transform !is null) data.transform.release();
if (data.inverseTransform !is null) data.inverseTransform.release();
@@ -750,9 +773,6 @@
*/
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(DRAW);
if (width < 0) {
x = x + width;
width = -width;
@@ -762,21 +782,25 @@
height = -height;
}
if (width is 0 || height is 0 || arcAngle is 0) return;
- handle.saveGraphicsState();
- NSAffineTransform transform = NSAffineTransform.transform();
+ NSAutoreleasePool pool = checkGC(DRAW);
+ try {
+ handle.saveGraphicsState();
+ NSAffineTransform transform = NSAffineTransform.transform();
CGFloat xOffset = data.drawXOffset, yOffset = data.drawYOffset;
- transform.translateXBy(x + xOffset + width / 2f, y + yOffset + height / 2f);
- transform.scaleXBy(width / 2f, height / 2f);
- NSBezierPath path = data.path;
+ transform.translateXBy(x + xOffset + width / 2f, y + yOffset + height / 2f);
+ transform.scaleXBy(width / 2f, height / 2f);
+ NSBezierPath path = data.path;
NSPoint center = NSPoint();
CGFloat sAngle = -startAngle;
CGFloat eAngle = -(startAngle + arcAngle);
- path.appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_(center, 1, sAngle, eAngle, arcAngle>0);
- path.transformUsingAffineTransform(transform);
- path.stroke();
- path.removeAllPoints();
- handle.restoreGraphicsState();
- NSGraphicsContext.setCurrentContext(context);
+ path.appendBezierPathWithArcWithCenter(center, 1, sAngle, eAngle, arcAngle>0);
+ path.transformUsingAffineTransform(transform);
+ path.stroke();
+ path.removeAllPoints();
+ handle.restoreGraphicsState();
+ } finally {
+ uncheckGC(pool);
+ }
}
/**
@@ -798,19 +822,19 @@
*/
public void drawFocus(int x, int y, int width, int height) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(CLIPPING | TRANSFORM);
-// int[] metric = new int[1];
-// OS.GetThemeMetric(OS.kThemeMetricFocusRectOutset, metric);
-// CGRect rect = new CGRect ();
-// rect.x = x + metric[0];
-// rect.y = y + metric[0];
-// rect.width = width - metric[0] * 2;
-// rect.height = height - metric[0] * 2;
-// OS.HIThemeDrawFocusRect(rect, true, handle, OS.kHIThemeOrientationNormal);
-// flush();
- NSGraphicsContext.setCurrentContext(context);
+ NSAutoreleasePool pool = checkGC(CLIPPING | TRANSFORM);
+ try {
+ // int[] metric = new int[1];
+ // OS.GetThemeMetric(OS.kThemeMetricFocusRectOutset, metric);
+ // CGRect rect = new CGRect ();
+ // rect.x = x + metric[0];
+ // rect.y = y + metric[0];
+ // rect.width = width - metric[0] * 2;
+ // rect.height = height - metric[0] * 2;
+ // OS.HIThemeDrawFocusRect(rect, true, handle, OS.kHIThemeOrientationNormal);
+ } finally {
+ uncheckGC(pool);
+ }
}
/**
@@ -883,9 +907,6 @@
}
void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple) {
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(CLIPPING | TRANSFORM);
NSImage imageHandle = srcImage.handle;
NSSize size = imageHandle.size();
int imgWidth = cast(int)size.width;
@@ -898,29 +919,34 @@
srcWidth is destWidth && destWidth is imgWidth &&
srcHeight is destHeight && destHeight is imgHeight;
if (srcX + srcWidth > imgWidth || srcY + srcHeight > imgHeight) {
- NSGraphicsContext.setCurrentContext(context);
DWT.error(DWT.ERROR_INVALID_ARGUMENT);
}
}
- if (srcImage.memGC !is null) srcImage.createAlpha();
- handle.saveGraphicsState();
- NSAffineTransform transform = NSAffineTransform.transform();
- transform.scaleXBy(1, -1);
- transform.translateXBy(0, -(destHeight + 2 * destY));
- transform.concat();
+ NSAutoreleasePool pool = checkGC(CLIPPING | TRANSFORM);
+ try {
+ if (srcImage.memGC !is null) {
+ srcImage.createAlpha();
+ }
+ handle.saveGraphicsState();
+ NSAffineTransform transform = NSAffineTransform.transform();
+ transform.scaleXBy(1, -1);
+ transform.translateXBy(0, -(destHeight + 2 * destY));
+ transform.concat();
NSRect srcRect = NSRect();
- srcRect.x = srcX;
- srcRect.y = srcY;
- srcRect.width = srcWidth;
- srcRect.height = srcHeight;
+ srcRect.x = srcX;
+ srcRect.y = imgHeight - (srcY + srcHeight);
+ srcRect.width = srcWidth;
+ srcRect.height = srcHeight;
NSRect destRect = NSRect();
- destRect.x = destX;
- destRect.y = destY;
- destRect.width = destWidth;
- destRect.height = destHeight;
+ destRect.x = destX;
+ destRect.y = destY;
+ destRect.width = destWidth;
+ destRect.height = destHeight;
imageHandle.drawInRect(destRect, srcRect, NSCompositeSourceOver, 1);
- handle.restoreGraphicsState();
- NSGraphicsContext.setCurrentContext(context);
+ handle.restoreGraphicsState();
+ } finally {
+ uncheckGC(pool);
+ }
}
/**
@@ -938,20 +964,21 @@
*/
public void drawLine(int x1, int y1, int x2, int y2) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(DRAW);
- NSBezierPath path = data.path;
+ NSAutoreleasePool pool = checkGC(DRAW);
+ try {
+ NSBezierPath path = data.path;
NSPoint pt = NSPoint();
- pt.x = x1 + data.drawXOffset;
- pt.y = y1 + data.drawYOffset;
- path.moveToPoint(pt);
- pt.x = x2 + data.drawXOffset;
- pt.y = y2 + data.drawYOffset;
- path.lineToPoint(pt);
- path.stroke();
- path.removeAllPoints();
- NSGraphicsContext.setCurrentContext(context);
+ pt.x = x1 + data.drawXOffset;
+ pt.y = y1 + data.drawYOffset;
+ path.moveToPoint(pt);
+ pt.x = x2 + data.drawXOffset;
+ pt.y = y2 + data.drawYOffset;
+ path.lineToPoint(pt);
+ path.stroke();
+ path.removeAllPoints();
+ } finally {
+ uncheckGC(pool);
+ }
}
/**
@@ -977,27 +1004,28 @@
*/
public void drawOval(int x, int y, int width, int height) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(DRAW);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
+ NSAutoreleasePool pool = checkGC(DRAW);
+ try {
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ NSBezierPath path = data.path;
+ NSRect rect = NSRect();
+ rect.x = x + data.drawXOffset;
+ rect.y = y + data.drawXOffset;
+ rect.width = width;
+ rect.height = height;
+ path.appendBezierPathWithOvalInRect(rect);
+ path.stroke();
+ path.removeAllPoints();
+ } finally {
+ uncheckGC(pool);
}
- NSBezierPath path = data.path;
- NSRect rect = NSRect();
- rect.x = x + data.drawXOffset;
- rect.y = y + data.drawXOffset;
- rect.width = width;
- rect.height = height;
- path.appendBezierPathWithOvalInRect(rect);
- path.stroke();
- path.removeAllPoints();
- NSGraphicsContext.setCurrentContext(context);
}
/**
@@ -1027,19 +1055,20 @@
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (path.handle is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(DRAW);
- handle.saveGraphicsState();
- NSAffineTransform transform = NSAffineTransform.transform();
- transform.translateXBy(data.drawXOffset, data.drawYOffset);
- transform.concat();
- NSBezierPath drawPath = data.path;
- drawPath.appendBezierPath(path.handle);
- drawPath.stroke();
- drawPath.removeAllPoints();
- handle.restoreGraphicsState();
- NSGraphicsContext.setCurrentContext(context);
+ NSAutoreleasePool pool = checkGC(DRAW);
+ try {
+ handle.saveGraphicsState();
+ NSAffineTransform transform = NSAffineTransform.transform();
+ transform.translateXBy(data.drawXOffset, data.drawYOffset);
+ transform.concat();
+ NSBezierPath drawPath = data.path;
+ drawPath.appendBezierPath(path.handle);
+ drawPath.stroke();
+ drawPath.removeAllPoints();
+ handle.restoreGraphicsState();
+ } finally {
+ uncheckGC(pool);
+ }
}
/**
@@ -1061,19 +1090,20 @@
*/
public void drawPoint(int x, int y) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(FOREGROUND_FILL);
+ NSAutoreleasePool pool = checkGC(FOREGROUND_FILL | CLIPPING | TRANSFORM);
+ try {
NSRect rect = NSRect();
- rect.x = x;
- rect.y = y;
- rect.width = 1;
- rect.height = 1;
- NSBezierPath path = data.path;
- path.appendBezierPathWithRect(rect);
- path.fill();
- path.removeAllPoints();
- NSGraphicsContext.setCurrentContext(context);
+ rect.x = x;
+ rect.y = y;
+ rect.width = 1;
+ rect.height = 1;
+ NSBezierPath path = data.path;
+ path.appendBezierPathWithRect(rect);
+ path.fill();
+ path.removeAllPoints();
+ } finally {
+ uncheckGC(pool);
+ }
}
/**
@@ -1096,26 +1126,27 @@
public void drawPolygon(int[] pointArray) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(DRAW);
if (pointArray.length < 4) return;
- CGFloat xOffset = data.drawXOffset, yOffset = data.drawYOffset;
- NSBezierPath path = data.path;
+ NSAutoreleasePool pool = checkGC(DRAW);
+ try {
+ float /*double*/ xOffset = data.drawXOffset, yOffset = data.drawYOffset;
+ NSBezierPath path = data.path;
NSPoint pt = NSPoint();
- pt.x = pointArray[0] + xOffset;
- pt.y = pointArray[1] + yOffset;
- path.moveToPoint(pt);
- int end = pointArray.length / 2 * 2;
- for (int i = 2; i < end; i+=2) {
- pt.x = pointArray[i] + xOffset;
- pt.y = pointArray[i+1] + yOffset;
- path.lineToPoint(pt);
+ pt.x = pointArray[0] + xOffset;
+ pt.y = pointArray[1] + yOffset;
+ path.moveToPoint(pt);
+ int end = pointArray.length / 2 * 2;
+ for (int i = 2; i < end; i+=2) {
+ pt.x = pointArray[i] + xOffset;
+ pt.y = pointArray[i+1] + yOffset;
+ path.lineToPoint(pt);
+ }
+ path.closePath();
+ path.stroke();
+ path.removeAllPoints();
+ } finally {
+ uncheckGC(pool);
}
- path.closePath();
- path.stroke();
- path.removeAllPoints();
- NSGraphicsContext.setCurrentContext(context);
}
/**
@@ -1138,25 +1169,26 @@
public void drawPolyline(int[] pointArray) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(DRAW);
if (pointArray.length < 4) return;
- CGFloat xOffset = data.drawXOffset, yOffset = data.drawYOffset;
- NSBezierPath path = data.path;
+ NSAutoreleasePool pool = checkGC(DRAW);
+ try {
+ float /*double*/ xOffset = data.drawXOffset, yOffset = data.drawYOffset;
+ NSBezierPath path = data.path;
NSPoint pt = NSPoint();
- pt.x = pointArray[0] + xOffset;
- pt.y = pointArray[1] + yOffset;
- path.moveToPoint(pt);
- int end = pointArray.length / 2 * 2;
- for (int i = 2; i < end; i+=2) {
- pt.x = pointArray[i] + xOffset;
- pt.y = pointArray[i+1] + yOffset;
- path.lineToPoint(pt);
+ pt.x = pointArray[0] + xOffset;
+ pt.y = pointArray[1] + yOffset;
+ path.moveToPoint(pt);
+ int end = pointArray.length / 2 * 2;
+ for (int i = 2; i < end; i+=2) {
+ pt.x = pointArray[i] + xOffset;
+ pt.y = pointArray[i+1] + yOffset;
+ path.lineToPoint(pt);
+ }
+ path.stroke();
+ path.removeAllPoints();
+ } finally {
+ uncheckGC(pool);
}
- path.stroke();
- path.removeAllPoints();
- NSGraphicsContext.setCurrentContext(context);
}
/**
@@ -1176,27 +1208,28 @@
*/
public void drawRectangle(int x, int y, int width, int height) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(DRAW);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
+ NSAutoreleasePool pool = checkGC(DRAW);
+ try {
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ NSRect rect = NSRect();
+ rect.x = x + data.drawXOffset;
+ rect.y = y + data.drawYOffset;
+ rect.width = width;
+ rect.height = height;
+ NSBezierPath path = data.path;
+ path.appendBezierPathWithRect(rect);
+ path.stroke();
+ path.removeAllPoints();
+ } finally {
+ uncheckGC(pool);
}
- NSRect rect = NSRect();
- rect.x = x + data.drawXOffset;
- rect.y = y + data.drawYOffset;
- rect.width = width;
- rect.height = height;
- NSBezierPath path = data.path;
- path.appendBezierPathWithRect(rect);
- path.stroke();
- path.removeAllPoints();
- NSGraphicsContext.setCurrentContext(context);
}
/**
@@ -1244,24 +1277,24 @@
*/
public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(DRAW);
if (arcWidth is 0 || arcHeight is 0) {
drawRectangle(x, y, width, height);
- NSGraphicsContext.setCurrentContext(context);
return;
}
- NSBezierPath path = data.path;
+ NSAutoreleasePool pool = checkGC(DRAW);
+ try {
+ NSBezierPath path = data.path;
NSRect rect = NSRect();
- rect.x = x + data.drawXOffset;
- rect.y = y + data.drawYOffset;
- rect.width = width;
- rect.height = height;
- path.appendBezierPathWithRoundedRect(rect, arcWidth, arcHeight);
- path.stroke();
- path.removeAllPoints();
- NSGraphicsContext.setCurrentContext(context);
+ rect.x = x + data.drawXOffset;
+ rect.y = y + data.drawYOffset;
+ rect.width = width;
+ rect.height = height;
+ path.appendBezierPathWithRoundedRect(rect, arcWidth, arcHeight);
+ path.stroke();
+ path.removeAllPoints();
+ } finally {
+ uncheckGC(pool);
+ }
}
/**
@@ -1395,26 +1428,27 @@
public void drawText (String string, int x, int y, int flags) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(CLIPPING | TRANSFORM | FONT | FOREGROUND_FILL);
- NSAttributedString str = createString(string, flags);
- if (data.paintRect is null) {
- handle.saveGraphicsState();
- NSAffineTransform transform = NSAffineTransform.transform();
- transform.scaleXBy(1, -1);
- transform.translateXBy(0, -(str.size().height + 2 * y));
- transform.concat();
+ NSAutoreleasePool pool = checkGC(CLIPPING | TRANSFORM | FONT | FOREGROUND_FILL);
+ try {
+ NSAttributedString str = createString(string, flags);
+ if (data.paintRect is null) {
+ handle.saveGraphicsState();
+ NSAffineTransform transform = NSAffineTransform.transform();
+ transform.scaleXBy(1, -1);
+ transform.translateXBy(0, -(str.size().height + 2 * y));
+ transform.concat();
+ }
+ NSPoint pt = NSPoint();
+ pt.x = x;
+ pt.y = y;
+ str.drawAtPoint(pt);
+ str.release();
+ if (data.paintRect is null) {
+ handle.restoreGraphicsState();
+ }
+ } finally {
+ uncheckGC(pool);
}
- NSPoint pt = NSPoint();
- pt.x = x;
- pt.y = y;
- str.drawAtPoint(pt);
- str.release();
- if (data.paintRect is null) {
- handle.restoreGraphicsState();
- }
- NSGraphicsContext.setCurrentContext(context);
}
/**
@@ -1469,9 +1503,6 @@
*/
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(FILL);
if (width < 0) {
x = x + width;
width = -width;
@@ -1481,23 +1512,27 @@
height = -height;
}
if (width is 0 || height is 0 || arcAngle is 0) return;
- handle.saveGraphicsState();
- NSAffineTransform transform = NSAffineTransform.transform();
+ NSAutoreleasePool pool = checkGC(FILL);
+ try {
+ handle.saveGraphicsState();
+ NSAffineTransform transform = NSAffineTransform.transform();
CGFloat xOffset = data.drawXOffset, yOffset = data.drawYOffset;
- transform.translateXBy(x + xOffset + width / 2f, y + yOffset + height / 2f);
- transform.scaleXBy(width / 2f, height / 2f);
- NSBezierPath path = data.path;
+ transform.translateXBy(x + xOffset + width / 2f, y + yOffset + height / 2f);
+ transform.scaleXBy(width / 2f, height / 2f);
+ NSBezierPath path = data.path;
NSPoint center = NSPoint();
- path.moveToPoint(center);
+ path.moveToPoint(center);
CGFloat sAngle = -startAngle;
CGFloat eAngle = -(startAngle + arcAngle);
- path.appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_(center, 1, sAngle, eAngle, arcAngle>0);
- path.closePath();
- path.transformUsingAffineTransform(transform);
- path.fill();
- path.removeAllPoints();
- handle.restoreGraphicsState();
- NSGraphicsContext.setCurrentContext(context);
+ path.appendBezierPathWithArcWithCenter(center, 1, sAngle, eAngle, arcAngle>0);
+ path.closePath();
+ path.transformUsingAffineTransform(transform);
+ path.fill();
+ path.removeAllPoints();
+ handle.restoreGraphicsState();
+ } finally {
+ uncheckGC(pool);
+ }
}
/**
@@ -1522,46 +1557,46 @@
*/
public void fillGradientRectangle(int x, int y, int width, int height, bool vertical) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(CLIPPING | TRANSFORM);
if ((width is 0) || (height is 0)) return;
-
- RGB backgroundRGB, foregroundRGB;
- backgroundRGB = getBackground().getRGB();
- foregroundRGB = getForeground().getRGB();
+ NSAutoreleasePool pool = checkGC(CLIPPING | TRANSFORM);
+ try {
+ RGB backgroundRGB, foregroundRGB;
+ backgroundRGB = getBackground().getRGB();
+ foregroundRGB = getForeground().getRGB();
- RGB fromRGB, toRGB;
- fromRGB = foregroundRGB;
- toRGB = backgroundRGB;
- bool swapColors = false;
- if (width < 0) {
- x += width; width = -width;
- if (! vertical) swapColors = true;
- }
- if (height < 0) {
- y += height; height = -height;
- if (vertical) swapColors = true;
- }
- if (swapColors) {
- fromRGB = backgroundRGB;
- toRGB = foregroundRGB;
- }
- if (fromRGB.equals(toRGB)) {
- fillRectangle(x, y, width, height);
- } else {
- NSColor startingColor = NSColor.colorWithDeviceRed(fromRGB.red / 255f, fromRGB.green / 255f, fromRGB.blue / 255f, data.alpha / 255f);
- NSColor endingColor = NSColor.colorWithDeviceRed(toRGB.red / 255f, toRGB.green / 255f, toRGB.blue / 255f, data.alpha / 255f);
+ RGB fromRGB, toRGB;
+ fromRGB = foregroundRGB;
+ toRGB = backgroundRGB;
+ bool swapColors = false;
+ if (width < 0) {
+ x += width; width = -width;
+ if (! vertical) swapColors = true;
+ }
+ if (height < 0) {
+ y += height; height = -height;
+ if (vertical) swapColors = true;
+ }
+ if (swapColors) {
+ fromRGB = backgroundRGB;
+ toRGB = foregroundRGB;
+ }
+ if (fromRGB.equals(toRGB)) {
+ fillRectangle(x, y, width, height);
+ } else {
+ NSColor startingColor = NSColor.colorWithDeviceRed(fromRGB.red / 255f, fromRGB.green / 255f, fromRGB.blue / 255f, data.alpha / 255f);
+ NSColor endingColor = NSColor.colorWithDeviceRed(toRGB.red / 255f, toRGB.green / 255f, toRGB.blue / 255f, data.alpha / 255f);
NSGradient gradient = (cast(NSGradient)(new NSGradient()).alloc()).initWithStartingColor(startingColor, endingColor);
NSRect rect = NSRect();
- rect.x = x;
- rect.y = y;
- rect.width = width;
- rect.height = height;
- gradient.drawInRect_angle_(rect, vertical ? 90 : 0);
- gradient.release();
+ rect.x = x;
+ rect.y = y;
+ rect.width = width;
+ rect.height = height;
+ gradient.drawInRect(rect, vertical ? 90 : 0);
+ gradient.release();
+ }
+ } finally {
+ uncheckGC(pool);
}
- NSGraphicsContext.setCurrentContext(context);
}
/**
@@ -1582,40 +1617,40 @@
*/
public void fillOval(int x, int y, int width, int height) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(FILL);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- NSBezierPath path = data.path;
+ NSAutoreleasePool pool = checkGC(FILL);
+ try {
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ NSBezierPath path = data.path;
NSRect rect = NSRect();
- rect.x = x;
- rect.y = y;
- rect.width = width;
- rect.height = height;
- path.appendBezierPathWithOvalInRect(rect);
- Pattern pattern = data.backgroundPattern;
- if (pattern !is null && pattern.gradient !is null) {
- fillPattern(path, pattern);
- } else {
- path.fill();
+ rect.x = x;
+ rect.y = y;
+ rect.width = width;
+ rect.height = height;
+ path.appendBezierPathWithOvalInRect(rect);
+ Pattern pattern = data.backgroundPattern;
+ if (pattern !is null && pattern.gradient !is null) {
+ fillPattern(path, pattern);
+ } else {
+ path.fill();
+ }
+ path.removeAllPoints();
+ } finally {
+ uncheckGC(pool);
}
- path.removeAllPoints();
- NSGraphicsContext.setCurrentContext(context);
}
void fillPattern(NSBezierPath path, Pattern pattern) {
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
+ handle.saveGraphicsState();
path.addClip();
pattern.gradient.drawFromPoint(pattern.pt1, pattern.pt2, OS.NSGradientDrawsAfterEndingLocation | OS.NSGradientDrawsBeforeStartingLocation);
- NSGraphicsContext.setCurrentContext(context);
+ handle.restoreGraphicsState();
}
/**
@@ -1645,19 +1680,20 @@
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (path.handle is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(FILL);
- NSBezierPath drawPath = data.path;
- drawPath.appendBezierPath(path.handle);
- Pattern pattern = data.backgroundPattern;
- if (pattern !is null && pattern.gradient !is null) {
- fillPattern(drawPath, pattern);
- } else {
- drawPath.fill();
+ NSAutoreleasePool pool = checkGC(FILL);
+ try {
+ NSBezierPath drawPath = data.path;
+ drawPath.appendBezierPath(path.handle);
+ Pattern pattern = data.backgroundPattern;
+ if (pattern !is null && pattern.gradient !is null) {
+ fillPattern(drawPath, pattern);
+ } else {
+ drawPath.fill();
+ }
+ drawPath.removeAllPoints();
+ } finally {
+ uncheckGC(pool);
}
- drawPath.removeAllPoints();
- NSGraphicsContext.setCurrentContext(context);
}
/**
@@ -1682,30 +1718,31 @@
public void fillPolygon(int[] pointArray) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(FILL);
if (pointArray.length < 4) return;
- NSBezierPath path = data.path;
+ NSAutoreleasePool pool = checkGC(FILL);
+ try {
+ NSBezierPath path = data.path;
NSPoint pt = NSPoint();
- pt.x = pointArray[0];
- pt.y = pointArray[1];
- path.moveToPoint(pt);
- int end = pointArray.length / 2 * 2;
- for (int i = 2; i < end; i+=2) {
- pt.x = pointArray[i];
- pt.y = pointArray[i+1];
- path.lineToPoint(pt);
+ pt.x = pointArray[0];
+ pt.y = pointArray[1];
+ path.moveToPoint(pt);
+ int end = pointArray.length / 2 * 2;
+ for (int i = 2; i < end; i+=2) {
+ pt.x = pointArray[i];
+ pt.y = pointArray[i+1];
+ path.lineToPoint(pt);
+ }
+ path.closePath();
+ Pattern pattern = data.backgroundPattern;
+ if (pattern !is null && pattern.gradient !is null) {
+ fillPattern(path, pattern);
+ } else {
+ path.fill();
+ }
+ path.removeAllPoints();
+ } finally {
+ uncheckGC(pool);
}
- path.closePath();
- Pattern pattern = data.backgroundPattern;
- if (pattern !is null && pattern.gradient !is null) {
- fillPattern(path, pattern);
- } else {
- path.fill();
- }
- path.removeAllPoints();
- NSGraphicsContext.setCurrentContext(context);
}
/**
@@ -1725,32 +1762,33 @@
*/
public void fillRectangle(int x, int y, int width, int height) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(FILL);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
+ NSAutoreleasePool pool = checkGC(FILL);
+ try {
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
NSRect rect = NSRect();
- rect.x = x;
- rect.y = y;
- rect.width = width;
- rect.height = height;
- NSBezierPath path = data.path;
- path.appendBezierPathWithRect(rect);
- Pattern pattern = data.backgroundPattern;
- if (pattern !is null && pattern.gradient !is null) {
- fillPattern(path, pattern);
- } else {
- path.fill();
+ rect.x = x;
+ rect.y = y;
+ rect.width = width;
+ rect.height = height;
+ NSBezierPath path = data.path;
+ path.appendBezierPathWithRect(rect);
+ Pattern pattern = data.backgroundPattern;
+ if (pattern !is null && pattern.gradient !is null) {
+ fillPattern(path, pattern);
+ } else {
+ path.fill();
+ }
+ path.removeAllPoints();
+ } finally {
+ uncheckGC(pool);
}
- path.removeAllPoints();
- NSGraphicsContext.setCurrentContext(context);
}
/**
@@ -1793,31 +1831,33 @@
*/
public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSGraphicsContext context = NSGraphicsContext.currentContext();
- NSGraphicsContext.setCurrentContext(handle);
- checkGC(FILL);
if (arcWidth is 0 || arcHeight is 0) {
fillRectangle(x, y, width, height);
return;
}
- NSBezierPath path = data.path;
+ NSAutoreleasePool pool = checkGC(FILL);
+ try {
+ NSBezierPath path = data.path;
NSRect rect = NSRect();
- rect.x = x;
- rect.y = y;
- rect.width = width;
- rect.height = height;
- path.appendBezierPathWithRoundedRect(rect, arcWidth, arcHeight);
- Pattern pattern = data.backgroundPattern;
- if (pattern !is null && pattern.gradient !is null) {
- fillPattern(path, pattern);
- } else {
- path.fill();
+ rect.x = x;
+ rect.y = y;
+ rect.width = width;
+ rect.height = height;
+ path.appendBezierPathWithRoundedRect(rect, arcWidth, arcHeight);
+ Pattern pattern = data.backgroundPattern;
+ if (pattern !is null && pattern.gradient !is null) {
+ fillPattern(path, pattern);
+ } else {
+ path.fill();
+ }
+ path.removeAllPoints();
+ } finally {
+ uncheckGC(pool);
}
- path.removeAllPoints();
- NSGraphicsContext.setCurrentContext(context);
}
void flush () {
+ handle.flushGraphics();
}
/**
@@ -1905,7 +1945,8 @@
}
/**
- * Returns the receiver's alpha value.
+ * Returns the receiver's alpha value. The alpha value
+ * is between 0 (transparent) and 255 (opaque).
*
* @return the alpha value
*
@@ -1979,7 +2020,7 @@
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
NSRect rect;
if (data.view !is null) {
- rect = data.view.bounds();
+ rect = data.view.visibleRect();
} else {
rect = NSRect();
if (data.image !is null) {
@@ -2038,7 +2079,7 @@
region.subtract(region);
NSRect rect = void;
if (data.view !is null) {
- rect = data.view.bounds();
+ rect = data.view.visibleRect();
} else {
rect = NSRect();
if (data.image !is null) {
@@ -2057,7 +2098,7 @@
}
if (data.clipPath !is null) {
NSBezierPath clip = data.clipPath.bezierPathByFlatteningPath();
- int count = clip.elementCount();
+ int count = (int)/*64*/clip.elementCount();
int pointCount = 0;
Region clipRgn = new Region(device);
int[] pointArray = new int[count * 2];
@@ -2065,7 +2106,7 @@
if (points is null) DWT.error(DWT.ERROR_NO_HANDLES);
NSPoint pt = NSPoint();
for (int i = 0; i < count; i++) {
- NSBezierPathElement element = clip.elementAtIndex_associatedPoints_(i, points);
+ NSBezierPathElement element = clip.elementAtIndex(i, points);
switch (element) {
case NSMoveToBezierPathElement:
if (pointCount !is 0) clipRgn.add(pointArray, pointCount);
@@ -2140,13 +2181,17 @@
*/
public FontMetrics getFontMetrics() {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- checkGC(FONT);
- NSFont font = data.font.handle;
+ NSAutoreleasePool pool = checkGC(FONT);
+ try {
+ NSFont font = data.font.handle;
int ascent = cast(int)(0.5f + font.ascender());
int descent = cast(int)(0.5f + (-font.descender() + font.leading()));
- String s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- int averageCharWidth = stringExtent(s).x / s.length();
- return FontMetrics.cocoa_new(ascent, descent, averageCharWidth, 0, ascent + descent);
+ String s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ int averageCharWidth = stringExtent(s).x / s.length();
+ return FontMetrics.cocoa_new(ascent, descent, averageCharWidth, 0, ascent + descent);
+ } finally {
+ uncheckGC(pool);
+ }
}
/**
@@ -2222,7 +2267,7 @@
*/
public int getInterpolation() {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- int interpolation = handle.imageInterpolation();
+ int interpolation = (int)/*64*/handle.imageInterpolation();
switch (interpolation) {
case OS.NSImageInterpolationDefault: return DWT.DEFAULT;
case OS.NSImageInterpolationNone: return DWT.NONE;
@@ -2572,7 +2617,8 @@
}
/**
- * Sets the receiver's alpha value.
+ * Sets the receiver's alpha value which must be
+ * between 0 (transparent) and 255 (opaque).
*
* This operation requires the operating system's advanced
* graphics subsystem which may not be available on some
@@ -3437,10 +3483,14 @@
public Point textExtent(String string, int flags) {
if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- checkGC(FONT);
- NSAttributedString str = createString(string, flags);
- NSSize size = str.size();
+ NSAutoreleasePool pool = checkGC(FONT);
+ try {
+ NSAttributedString str = createString(string, flags);
+ NSSize size = str.size();
return new Point(cast(int)size.width, cast(int)size.height);
+ } finally {
+ uncheckGC(pool);
+ }
}
/**
@@ -3454,4 +3504,12 @@
return Format("GC {{}{}" , handle , "}");
}
+void uncheckGC(NSAutoreleasePool pool) {
+ NSView view = data.view;
+ if (view !is null && data.paintRect is null) {
+ if (data.thread !is Thread.currentThread()) flush();
+ }
+ if (pool !is null) pool.release();
}
+
+}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/GCData.d
--- a/dwt/graphics/GCData.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/GCData.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.GCData;
@@ -37,6 +37,7 @@
* within the packages provided by DWT. It is not available on all
* platforms, and should never be called from application code.
*
+ * @see Sample code and further information
*/
public final class GCData {
public Device device;
@@ -68,8 +69,12 @@
public NSAffineTransform transform, inverseTransform;
public NSBezierPath clipPath;
public NSView view;
- public NSSize* size;
+ public NSSize* size;
+ public NSRect* windowRect, visibleRect;
+ public Thread thread;
public NSRect paintRectStruct;
public NSSize sizeStruct;
+ public NSRect windowRectStruct;
+ public NSRect visibleRectStruct;
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/GlyphMetrics.d
--- a/dwt/graphics/GlyphMetrics.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/GlyphMetrics.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.GlyphMetrics;
@@ -35,6 +35,7 @@
*
* @see TextStyle
* @see TextLayout
+ * @see Sample code and further information
*
* @since 3.2
*/
@@ -59,13 +60,17 @@
* Constructs an instance of this class with the given
* ascent, descent and width values.
*
+ * @param ascent the GlyphMetrics ascent
+ * @param descent the GlyphMetrics descent
+ * @param width the GlyphMetrics width
+ *
* @exception IllegalArgumentException
* - ERROR_INVALID_ARGUMENT - if the ascent, descent or width argument is negative
*
*/
public this(int ascent, int descent, int width) {
if (ascent < 0 || descent < 0 || width < 0) {
- DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+ DWT.error(DWT.ERROR_INVALID_ARGUMENT);
}
this.ascent = ascent;
this.descent = descent;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Image.d
--- a/dwt/graphics/Image.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Image.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Image;
@@ -19,13 +19,15 @@
import dwt.DWT;
import dwt.DWTError;
import dwt.DWTException;
+import dwt.internal.C;
import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSAutoreleasePool;
import dwt.internal.cocoa.NSBitmapImageRep;
import dwt.internal.cocoa.NSGraphicsContext;
import dwt.internal.cocoa.NSImage;
import dwt.internal.cocoa.NSImageRep;
import dwt.internal.cocoa.NSSize;
-import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSThread;
import dwt.internal.cocoa.OS;
import tango.text.convert.Format;
@@ -90,6 +92,9 @@
* @see Color
* @see ImageData
* @see ImageLoader
+ * @see Image snippets
+ * @see DWT Examples: GraphicsExample, ImageAnalyzer
+ * @see Sample code and further information
*/
public final class Image : Resource, Drawable {
@@ -191,8 +196,14 @@
*/
public this(Device device, int width, int height) {
super(device);
- init_(width, height);
- init_();
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ init_(width, height);
+ init_();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -200,11 +211,11 @@
* provided image, with an appearance that varies depending
* on the value of the flag. The possible flag values are:
*
- * - IMAGE_COPY
+ * - {@link DWT#IMAGE_COPY}
* - the result is an identical copy of srcImage
- * - IMAGE_DISABLE
+ * - {@link DWT#IMAGE_DISABLE}
* - the result is a copy of srcImage which has a disabled look
- * - IMAGE_GRAY
+ * - {@link DWT#IMAGE_GRAY}
* - the result is a copy of srcImage which has a gray scale look
*
*
@@ -238,37 +249,40 @@
default:
DWT.error(DWT.ERROR_INVALID_ARGUMENT);
}
- device = this.device;
- this.type = srcImage.type;
- /* Get source image size */
- NSSize size = srcImage.handle.size();
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ device = this.device;
+ this.type = srcImage.type;
+ /* Get source image size */
+ NSSize size = srcImage.handle.size();
int width = cast(int)size.width;
int height = cast(int)size.height;
- NSBitmapImageRep srcRep = srcImage.imageRep;
+ NSBitmapImageRep srcRep = srcImage.imageRep;
NSInteger bpr = srcRep.bytesPerRow();
- /* Copy transparent pixel and alpha data when necessary */
- transparentPixel = srcImage.transparentPixel;
- alpha = srcImage.alpha;
- if (srcImage.alphaData !is null) {
- alphaData = new byte[srcImage.alphaData.length];
- System.arraycopy(srcImage.alphaData, 0, alphaData, 0, alphaData.length);
- }
+ /* Copy transparent pixel and alpha data when necessary */
+ transparentPixel = srcImage.transparentPixel;
+ alpha = srcImage.alpha;
+ if (srcImage.alphaData !is null) {
+ alphaData = new byte[srcImage.alphaData.length];
+ System.arraycopy(srcImage.alphaData, 0, alphaData, 0, alphaData.length);
+ }
- /* Create the image */
+ /* Create the image */
handle = cast(NSImage)(new NSImage()).alloc();
- handle = handle.initWithSize(size);
+ handle = handle.initWithSize(size);
NSBitmapImageRep rep = imageRep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc();
- rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(null, cast(NSInteger) width, cast(NSInteger) height, srcRep.bitsPerSample(), srcRep.samplesPerPixel(), srcRep.samplesPerPixel() is 4, srcRep.isPlanar(), OS.NSDeviceRGBColorSpace, NSAlphaFirstBitmapFormat | NSAlphaNonpremultipliedBitmapFormat, srcRep.bytesPerRow(), srcRep.bitsPerPixel());
- handle.addRepresentation(rep);
-
+ rep = rep.initWithBitmapDataPlanes(null, width, height, srcRep.bitsPerSample(), srcRep.samplesPerPixel(), srcRep.samplesPerPixel() is 4, srcRep.isPlanar(), OS.NSDeviceRGBColorSpace, NSAlphaFirstBitmapFormat | NSAlphaNonpremultipliedBitmapFormat, srcRep.bytesPerRow(), srcRep.bitsPerPixel());
+ handle.addRepresentation(rep);
+
objc.id data = rep.bitmapData();
- OS.memmove(data, srcImage.imageRep.bitmapData(), cast(size_t) (width * height * 4));
- if (flag !is DWT.IMAGE_COPY) {
-
- /* Apply transformation */
- switch (flag) {
+ OS.memmove(data, srcImage.imageRep.bitmapData(), width * height * 4);
+ if (flag !is DWT.IMAGE_COPY) {
+
+ /* Apply transformation */
+ switch (flag) {
case DWT.IMAGE_DISABLE: {
Color zeroColor = device.getSystemColor(DWT.COLOR_WIDGET_NORMAL_SHADOW);
RGB zeroRGB = zeroColor.getRGB();
@@ -280,7 +294,7 @@
byte oneRed = cast(byte)oneRGB.red;
byte oneGreen = cast(byte)oneRGB.green;
byte oneBlue = cast(byte)oneRGB.blue;
- byte[] line = new byte[bpr];
+ byte[] line = new byte[(int)/*64*/bpr];
for (int y=0; y> 3)] |= (1 << (7 - (x & 0x7)));
- } else {
- maskData[maskOffset + (x >> 3)] &= ~(1 << (7 - (x & 0x7)));
+ data.transparentPixel = transparentPixel;
+ if (transparentPixel is -1 && type is DWT.ICON) {
+ /* Get the icon mask data */
+ int maskPad = 2;
+ int maskBpl = (((width + 7) / 8) + (maskPad - 1)) / maskPad * maskPad;
+ byte[] maskData = new byte[height * maskBpl];
+ int offset = 0, maskOffset = 0;
+ for (int y = 0; y> 3)] |= (1 << (7 - (x & 0x7)));
+ } else {
+ maskData[maskOffset + (x >> 3)] &= ~(1 << (7 - (x & 0x7)));
+ }
+ offset += 4;
}
- offset += 4;
+ maskOffset += maskBpl;
}
- maskOffset += maskBpl;
+ data.maskData = maskData;
+ data.maskPad = maskPad;
+ }
+ for (int i = 0; i < srcData.length; i+= 4) {
+ srcData[i] = 0;
}
- data.maskData = maskData;
- data.maskPad = maskPad;
+ data.alpha = alpha;
+ if (alpha is -1 && alphaData !is null) {
+ data.alphaData = new byte[alphaData.length];
+ System.arraycopy(alphaData, 0, data.alphaData, 0, alphaData.length);
+ }
+ return data;
+ } finally {
+ if (pool !is null) pool.release();
}
- for (int i = 0; i < srcData.length; i+= 4) {
- srcData[i] = 0;
- }
- data.alpha = alpha;
- if (alpha is -1 && alphaData !is null) {
- data.alphaData = new byte[alphaData.length];
- System.arraycopy(alphaData, 0, data.alphaData, 0, alphaData.length);
- }
- return data;
}
/**
@@ -707,11 +770,18 @@
Image image = new Image(device);
image.type = type;
image.handle = nsImage;
- NSImageRep rep = nsImage.bestRepresentationForDevice(null);
- if (rep.isKindOfClass(NSBitmapImageRep.static_class())) {
- image.imageRep = new NSBitmapImageRep(rep.id_);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ NSImageRep rep = nsImage.bestRepresentationForDevice(null);
+ if (rep.isKindOfClass(OS.class_NSBitmapImageRep)) {
+ rep.retain();
+ image.imageRep = new NSBitmapImageRep(rep.id_);
+ }
+ return image;
+ } finally {
+ if (pool !is null) pool.release();
}
- return image;
}
/**
@@ -744,7 +814,7 @@
size.height = height;
handle = handle.initWithSize(size);
NSBitmapImageRep rep = imageRep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc();
- rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(null, cast(NSInteger) width, cast(NSInteger) height, 8, 3, false, false, OS.NSDeviceRGBColorSpace, NSAlphaFirstBitmapFormat | NSAlphaNonpremultipliedBitmapFormat, cast(NSInteger) (width * 4), 32);
+ rep = rep.initWithBitmapDataPlanes_(null, width, height, 8, 3, false, false, OS.NSDeviceRGBColorSpace, NSAlphaFirstBitmapFormat | NSAlphaNonpremultipliedBitmapFormat, width * 4, 32);
OS.memset(rep.bitmapData(), 0xFF, cast(size_t) (width * height * 4));
handle.addRepresentation(rep);
// rep.release();
@@ -853,8 +923,7 @@
size.height = height;
handle = handle.initWithSize(size);
NSBitmapImageRep rep = imageRep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc();
- rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(
- null, cast(NSInteger) width, cast(NSInteger) height, 8, hasAlpha ? 4 : 3, hasAlpha, false, OS.NSDeviceRGBColorSpace, NSAlphaFirstBitmapFormat | NSAlphaNonpremultipliedBitmapFormat, cast(NSInteger) bpr, 32);
+ rep = rep.initWithBitmapDataPlanes(0, width, height, 8, hasAlpha ? 4 : 3, hasAlpha, false, OS.NSDeviceRGBColorSpace, OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, bpr, 32);
OS.memmove(rep.bitmapData(), buffer.ptr, dataSize);
handle.addRepresentation(rep);
// rep.release();
@@ -878,39 +947,43 @@
if (type !is DWT.BITMAP || memGC !is null) {
DWT.error(DWT.ERROR_INVALID_ARGUMENT);
}
- NSGraphicsContext current = NSGraphicsContext.currentContext();
- NSBitmapImageRep rep = imageRep;
- if (imageRep.hasAlpha()) {
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ NSBitmapImageRep rep = imageRep;
+ if (imageRep.hasAlpha()) {
NSInteger bpr = width * 4;
rep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc();
objc.id bitmapData = imageRep.bitmapData();
if (data.bitmapDataAddress !is null) OS.free(data.bitmapDataAddress);
- data.bitmapDataAddress = cast(ubyte*) OS.malloc((void*).sizeof);
- OS.memmove(data.bitmapDataAddress, bitmapData, (void*).sizeof);
- rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(
- &data.bitmapDataAddress, cast(NSInteger) width, cast(NSInteger) height, 8, 3, false, false, OS.NSDeviceRGBColorSpace, NSAlphaFirstBitmapFormat , bpr, 32);
- rep.autorelease();
+ data.bitmapDataAddress = cast(ubyte*) OS.malloc(C.PTR_SIZEOF);
+ OS.memmove(data.bitmapDataAddress, bitmapData, C.PTR_SIZEOF);
+ rep = rep.initWithBitmapDataPlanes(data.bitmapDataAddress, width, height, 8, 3, false, false, OS.NSDeviceRGBColorSpace, OS.NSAlphaFirstBitmapFormat , bpr, 32);
+ rep.autorelease();
+ }
+ handle.setCacheMode(OS.NSImageCacheNever);
+ NSGraphicsContext context = NSGraphicsContext.graphicsContextWithBitmapImageRep(rep);
+ NSGraphicsContext.setCurrentContext(context);
+ NSAffineTransform transform = NSAffineTransform.transform();
+ NSSize size = handle.size();
+ transform.translateXBy(0, size.height);
+ transform.scaleXBy(1, -1);
+ transform.set();
+ if (data !is null) {
+ int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
+ if ((data.style & mask) is 0) {
+ data.style |= DWT.LEFT_TO_RIGHT;
+ }
+ data.device = device;
+ data.background = device.COLOR_WHITE.handle;
+ data.foreground = device.COLOR_BLACK.handle;
+ data.font = device.systemFont;
+ data.image = this;
+ }
+ return context.id_;
+ } finally {
+ if (pool !is null) pool.release();
}
- NSGraphicsContext context = NSGraphicsContext.graphicsContextWithBitmapImageRep(rep);
- NSGraphicsContext.setCurrentContext(context);
- NSAffineTransform transform = NSAffineTransform.transform();
- NSSize size = handle.size();
- transform.translateXBy(0, size.height);
- transform.scaleXBy(1, -1);
- transform.set();
- if (data !is null) {
- int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
- if ((data.style & mask) is 0) {
- data.style |= DWT.LEFT_TO_RIGHT;
- }
- data.device = device;
- data.background = device.COLOR_WHITE.handle;
- data.foreground = device.COLOR_BLACK.handle;
- data.font = device.systemFont;
- data.image = this;
- }
- NSGraphicsContext.setCurrentContext(current);
- return context.id_;
}
/**
@@ -927,8 +1000,15 @@
* @param data the platform specific GC data
*/
public void internal_dispose_GC (objc.id context, GCData data) {
- if (data.bitmapDataAddress !is null) OS.free(data.bitmapDataAddress);
- data.bitmapDataAddress = null;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ if (data.bitmapDataAddress !is null) OS.free(data.bitmapDataAddress);
+ data.bitmapDataAddress = null;
+// handle.setCacheMode(OS.NSImageCacheDefault);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/ImageData.d
--- a/dwt/graphics/ImageData.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/ImageData.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/ImageDataLoader.d
--- a/dwt/graphics/ImageDataLoader.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/ImageDataLoader.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.ImageDataLoader;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/ImageLoader.d
--- a/dwt/graphics/ImageLoader.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/ImageLoader.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/ImageLoaderEvent.d
--- a/dwt/graphics/ImageLoaderEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/ImageLoaderEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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
@@ -9,11 +9,12 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.ImageLoaderEvent;
+
import dwt.internal.DWTEventObject;
import tango.text.convert.Format;
@@ -38,6 +39,7 @@
*
* @see ImageLoader
* @see ImageLoaderListener
+ * @see Sample code and further information
*/
public class ImageLoaderEvent : DWTEventObject {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/ImageLoaderListener.d
--- a/dwt/graphics/ImageLoaderListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/ImageLoaderListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
@@ -9,10 +9,11 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.ImageLoaderListener;
+
import dwt.internal.DWTEventListener;
import dwt.graphics.ImageLoaderEvent;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/LineAttributes.d
--- a/dwt/graphics/LineAttributes.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/LineAttributes.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.LineAttributes;
@@ -28,6 +28,7 @@
*
* @see GC#getLineAttributes()
* @see GC#setLineAttributes(LineAttributes)
+ * @see Sample code and further information
*
* @since 3.3
*/
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/PaletteData.d
--- a/dwt/graphics/PaletteData.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/PaletteData.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.PaletteData;
@@ -56,6 +56,7 @@
*
* @see Image
* @see RGB
+ * @see Sample code and further information
*/
public final class PaletteData {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Path.d
--- a/dwt/graphics/Path.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Path.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Path;
@@ -18,6 +18,7 @@
import dwt.DWTError;
import dwt.DWTException;
import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSAutoreleasePool;
import dwt.internal.cocoa.NSBezierPath;
import dwt.internal.cocoa.NSLayoutManager;
import dwt.internal.cocoa.NSPoint;
@@ -27,6 +28,7 @@
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSTextContainer;
import dwt.internal.cocoa.NSTextStorage;
+import dwt.internal.cocoa.NSThread;
import dwt.internal.cocoa.OS;
import tango.text.convert.Format;
@@ -56,6 +58,10 @@
* This class requires the operating system's advanced graphics subsystem
* which may not be available on some platforms.
*
+ *
+ * @see Path, Pattern snippets
+ * @see DWT Example: GraphicsExample
+ * @see Sample code and further information
*
* @since 3.1
*/
@@ -99,34 +105,106 @@
*/
public this (Device device) {
super(device);
- handle = NSBezierPath.bezierPath();
- if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
- handle.retain();
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ handle = NSBezierPath.bezierPath();
+ if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
+ handle.retain();
handle.moveToPoint(NSPoint());
init_();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
-public this (Device device, Path path, float flatness) {
+/**
+ * Constructs a new Path that is a copy of path
. If
+ * flatness
is less than or equal to zero, an unflatten
+ * copy of the path is created. Otherwise, it specifies the maximum
+ * error between the path and its flatten copy. Smaller numbers give
+ * better approximation.
+ *
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ *
+ *
+ * @param device the device on which to allocate the path
+ * @param path the path to make a copy
+ * @param flatness the flatness value
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the device is null and there is no current device
+ * - ERROR_NULL_ARGUMENT - if the path is null
+ * - ERROR_INVALID_ARGUMENT - if the path has been disposed
+ *
+ * @exception DWTException
+ * - ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
+ *
+ * @exception DWTError
+ * - ERROR_NO_HANDLES if a handle for the path could not be obtained
+ *
+ *
+ * @see #dispose()
+ * @since 3.4
+ */
super(device);
- if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- if (path.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- flatness = Math.max(0, flatness);
- if (flatness is 0) {
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ if (path.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+ flatness = Math.max(0, flatness);
+ if (flatness is 0) {
handle = new NSBezierPath(path.handle.copy().id_);
- } else {
+ } else {
CGFloat defaultFlatness = NSBezierPath.defaultFlatness();
- NSBezierPath.setDefaultFlatness(flatness);
- handle = path.handle.bezierPathByFlatteningPath();
- NSBezierPath.setDefaultFlatness(defaultFlatness);
+ NSBezierPath.setDefaultFlatness(flatness);
+ handle = path.handle.bezierPathByFlatteningPath();
+ NSBezierPath.setDefaultFlatness(defaultFlatness);
+ }
+ if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
+ init_();
+ } finally {
+ if (pool !is null) pool.release();
}
- if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
- init_();
}
-public this (Device device, PathData data) {
+/**
+ * Constructs a new Path with the specifed PathData.
+ *
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ *
+ *
+ * @param device the device on which to allocate the path
+ * @param data the data for the path
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the device is null and there is no current device
+ * - ERROR_NULL_ARGUMENT - if the data is null
+ *
+ * @exception DWTException
+ * - ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
+ *
+ * @exception DWTError
+ * - ERROR_NO_HANDLES if a handle for the path could not be obtained
+ *
+ *
+ * @see #dispose()
+ * @since 3.4
+ */
this(device);
- if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
init_(data);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -160,16 +238,22 @@
*/
public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSAffineTransform transform = NSAffineTransform.transform();
- transform.translateXBy(x + width / 2f, y + height / 2f);
- transform.scaleXBy(width / 2f, height / 2f);
- NSBezierPath path = NSBezierPath.bezierPath();
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ NSAffineTransform transform = NSAffineTransform.transform();
+ transform.translateXBy(x + width / 2f, y + height / 2f);
+ transform.scaleXBy(width / 2f, height / 2f);
+ NSBezierPath path = NSBezierPath.bezierPath();
NSPoint center = NSPoint();
CGFloat sAngle = -startAngle;
CGFloat eAngle = -(startAngle + arcAngle);
- path.appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_(center, 1, sAngle, eAngle, arcAngle>0);
- path.transformUsingAffineTransform(transform);
- handle.appendBezierPath(path);
+ path.appendBezierPathWithArcWithCenter(center, 1, sAngle, eAngle, arcAngle>0);
+ path.transformUsingAffineTransform(transform);
+ handle.appendBezierPath(path);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -189,7 +273,13 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (path.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- handle.appendBezierPath(path.handle);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ handle.appendBezierPath(path.handle);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -211,7 +301,13 @@
rect.y = y;
rect.width = width;
rect.height = height;
- handle.appendBezierPathWithRect(rect);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ handle.appendBezierPathWithRect(rect);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -235,42 +331,48 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (font is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (font.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- NSString str = NSString.stringWith(stri);
- NSTextStorage textStorage = (cast(NSTextStorage)(new NSTextStorage()).alloc());
- textStorage.initWithString_(str);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ NSString str = NSString.stringWith(stri);
+ NSTextStorage textStorage = (cast(NSTextStorage)(new NSTextStorage()).alloc());
+ textStorage.initWithString(str);
NSLayoutManager layoutManager = cast(NSLayoutManager)(new NSLayoutManager()).alloc().init();
NSTextContainer textContainer = cast(NSTextContainer)(new NSTextContainer()).alloc();
NSSize size = NSSize();
size.width = CGFloat.max; //Float.MAX_VALUE;
size.height = CGFloat.max; //Float.MAX_VALUE;
- textContainer.initWithContainerSize(size);
- textStorage.addLayoutManager(layoutManager);
- layoutManager.addTextContainer(textContainer);
+ textContainer.initWithContainerSize(size);
+ textStorage.addLayoutManager(layoutManager);
+ layoutManager.addTextContainer(textContainer);
NSRange range = NSRange();
- range.length = str.length();
- textStorage.beginEditing();
- textStorage.addAttribute(OS.NSFontAttributeName(), font.handle, range);
- textStorage.endEditing();
- range = layoutManager.glyphRangeForTextContainer(textContainer);
- if (range.length !is 0) {
+ range.length = str.length();
+ textStorage.beginEditing();
+ textStorage.addAttribute(OS.NSFontAttributeName, font.handle, range);
+ textStorage.endEditing();
+ range = layoutManager.glyphRangeForTextContainer(textContainer);
+ if (range.length !is 0) {
NSGlyph* glyphs = cast(NSGlyph*) OS.malloc(4 * range.length * 2);
- layoutManager.getGlyphs(glyphs, range);
- NSBezierPath path = NSBezierPath.bezierPath();
+ layoutManager.getGlyphs(glyphs, range);
+ NSBezierPath path = NSBezierPath.bezierPath();
NSPoint point = NSPoint();
- point.x = x;
- point.y = y;
- path.moveToPoint(point);
- path.appendBezierPathWithGlyphs(glyphs, range.length, font.handle);
- NSAffineTransform transform = NSAffineTransform.transform();
- transform.scaleXBy(1, -1);
- transform.translateXBy(0, -((2*y) + textStorage.size().height));
- path.transformUsingAffineTransform(transform);
- OS.free(glyphs);
- handle.appendBezierPath(path);
+ point.x = x;
+ point.y = y;
+ path.moveToPoint(point);
+ path.appendBezierPathWithGlyphs(glyphs, range.length, font.handle);
+ NSAffineTransform transform = NSAffineTransform.transform();
+ transform.scaleXBy(1, -1);
+ transform.translateXBy(0, -((2*y) + textStorage.size().height));
+ path.transformUsingAffineTransform(transform);
+ OS.free(glyphs);
+ handle.appendBezierPath(path);
+ }
+ textContainer.release();
+ layoutManager.release();
+ textStorage.release();
+ } finally {
+ if (pool !is null) pool.release();
}
- textContainer.release();
- layoutManager.release();
- textStorage.release();
}
/**
@@ -284,7 +386,13 @@
*/
public void close() {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- handle.closePath();
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ handle.closePath();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -314,12 +422,18 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
-// gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH);
- //TODO outline
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ // gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH);
+ //TODO outline
NSPoint point = NSPoint();
- point.x = x;
- point.y = y;
- return handle.containsPoint(point);
+ point.x = x;
+ point.y = y;
+ return handle.containsPoint(point);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -338,16 +452,22 @@
*/
public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSPoint pt = NSPoint();
- pt.x = x;
- pt.y = y;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ NSPoint pt = NSPoint();
+ pt.x = x;
+ pt.y = y;
NSPoint ct1 = NSPoint();
- ct1.x = cx1;
- ct1.y = cy1;
+ ct1.x = cx1;
+ ct1.y = cy1;
NSPoint ct2 = NSPoint();
- ct2.x = cx2;
- ct2.y = cy2;
- handle.curveToPoint(pt, ct1, ct2);
+ ct2.x = cx2;
+ ct2.y = cy2;
+ handle.curveToPoint(pt, ct1, ct2);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
void destroy() {
@@ -374,11 +494,17 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (bounds.length < 4) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- NSRect rect = handle.controlPointBounds();
- bounds[0] = rect.x;
- bounds[1] = rect.y;
- bounds[2] = rect.width;
- bounds[3] = rect.height;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ NSRect rect = handle.controlPointBounds();
+ bounds[0] = (float)/*64*/rect.x;
+ bounds[1] = (float)/*64*/rect.y;
+ bounds[2] = (float)/*64*/rect.width;
+ bounds[3] = (float)/*64*/rect.height;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -399,9 +525,15 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (point is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (point.length < 2) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- NSPoint pt = handle.currentPoint();
- point[0] = pt.x;
- point[1] = pt.y;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ NSPoint pt = handle.currentPoint();
+ point[0] = (float)/*64*/pt.x;
+ point[1] = (float)/*64*/pt.y;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -417,30 +549,33 @@
*/
public PathData getPathData() {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- int count = handle.elementCount();
- int pointCount = 0, typeCount = 0;
- byte[] types = new byte[count];
- float[] pointArray = new float[count * 6];
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ int count = (int)/*64*/handle.elementCount();
+ int pointCount = 0, typeCount = 0;
+ byte[] types = new byte[count];
+ float[] pointArray = new float[count * 6];
NSPointArray points = cast(NSPointArray) OS.malloc(3 * NSPoint.sizeof);
if (points is null) DWT.error(DWT.ERROR_NO_HANDLES);
NSPoint pt = NSPoint();
for (NSInteger i = 0; i < count; i++) {
- NSBezierPathElement element = handle.elementAtIndex_associatedPoints_(i, points);
- switch (element) {
+ NSBezierPathElement element = handle.elementAtIndex(i, points);
+ switch (element) {
case NSMoveToBezierPathElement:
- types[typeCount++] = DWT.PATH_MOVE_TO;
+ types[typeCount++] = DWT.PATH_MOVE_TO;
OS.memmove(&pt, points, NSPoint.sizeof);
pointArray[pointCount++] = cast(int)pt.x;
pointArray[pointCount++] = cast(int)pt.y;
- break;
+ break;
case NSLineToBezierPathElement:
- types[typeCount++] = DWT.PATH_LINE_TO;
+ types[typeCount++] = DWT.PATH_LINE_TO;
OS.memmove(&pt, points, NSPoint.sizeof);
pointArray[pointCount++] = cast(int)pt.x;
pointArray[pointCount++] = cast(int)pt.y;
- break;
+ break;
case NSCurveToBezierPathElement:
- types[typeCount++] = DWT.PATH_CUBIC_TO;
+ types[typeCount++] = DWT.PATH_CUBIC_TO;
OS.memmove(&pt, points, NSPoint.sizeof);
pointArray[pointCount++] = cast(int)pt.x;
pointArray[pointCount++] = cast(int)pt.y;
@@ -450,22 +585,25 @@
OS.memmove(&pt, points + NSPoint.sizeof + NSPoint.sizeof, NSPoint.sizeof);
pointArray[pointCount++] = cast(int)pt.x;
pointArray[pointCount++] = cast(int)pt.y;
- break;
+ break;
case NSClosePathBezierPathElement:
- types[typeCount++] = DWT.PATH_CLOSE;
- break;
+ types[typeCount++] = DWT.PATH_CLOSE;
+ break;
+ }
}
+ OS.free(points);
+ if (pointCount !is pointArray.length) {
+ float[] temp = new float[pointCount];
+ System.arraycopy(pointArray, 0, temp, 0, pointCount);
+ pointArray = temp;
+ }
+ PathData data = new PathData();
+ data.types = types;
+ data.points = pointArray;
+ return data;
+ } finally {
+ if (pool !is null) pool.release();
}
- OS.free(points);
- if (pointCount !is pointArray.length) {
- float[] temp = new float[pointCount];
- System.arraycopy(pointArray, 0, temp, 0, pointCount);
- pointArray = temp;
- }
- PathData data = new PathData();
- data.types = types;
- data.points = pointArray;
- return data;
}
void init_(PathData data) {
@@ -522,10 +660,16 @@
*/
public void lineTo(float x, float y) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSPoint pt = NSPoint();
- pt.x = x;
- pt.y = y;
- handle.lineToPoint(pt);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ NSPoint pt = NSPoint();
+ pt.x = x;
+ pt.y = y;
+ handle.lineToPoint(pt);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -542,11 +686,16 @@
*/
public void moveTo(float x, float y) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSPoint pt = NSPoint();
- pt.x = x;
- pt.y = y;
- handle.moveToPoint(pt);
-
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ NSPoint pt = NSPoint();
+ pt.x = x;
+ pt.y = y;
+ handle.moveToPoint(pt);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -563,13 +712,19 @@
*/
public void quadTo(float cx, float cy, float x, float y) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSPoint pt = NSPoint();
- pt.x = x;
- pt.y = y;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ NSPoint pt = NSPoint();
+ pt.x = x;
+ pt.y = y;
NSPoint ct = NSPoint();
- ct.x = cx;
- ct.y = cy;
- handle.curveToPoint(pt, ct, ct);
+ ct.x = cx;
+ ct.y = cy;
+ handle.curveToPoint(pt, ct, ct);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/PathData.d
--- a/dwt/graphics/PathData.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/PathData.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.PathData;
@@ -18,6 +18,7 @@
* Instances of this class describe device-independent paths.
*
* @see Path
+ * @see Sample code and further information
*
* @since 3.1
*/
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Pattern.d
--- a/dwt/graphics/Pattern.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Pattern.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Pattern;
@@ -18,9 +18,11 @@
import dwt.DWT;
import dwt.DWTError;
import dwt.DWTException;
+import dwt.internal.cocoa.NSAutoreleasePool;
import dwt.internal.cocoa.NSColor;
import dwt.internal.cocoa.NSGradient;
import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSThread;
import tango.text.convert.Format;
@@ -44,6 +46,10 @@
* which may not be available on some platforms.
*
*
+ * @see Path, Pattern snippets
+ * @see DWT Example: GraphicsExample
+ * @see Sample code and further information
+ *
* @since 3.1
*/
public class Pattern : Resource {
@@ -85,10 +91,16 @@
super(device);
if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- this.image = image;
- color = NSColor.colorWithPatternImage(image.handle);
- color.retain();
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ this.image = image;
+ color = NSColor.colorWithPatternImage(image.handle);
+ color.retain();
init_();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -168,20 +180,26 @@
if (color1.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
if (color2 is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (color2.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- pt1 = NSPoint();
- pt2 = NSPoint();
- pt1.x = x1;
- pt1.y = y1;
- pt2.x = x2;
- pt2.y = y2;
- this.color1 = color1.handle;
- this.color2 = color2.handle;
- this.alpha1 = alpha1;
- this.alpha2 = alpha2;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ pt1 = NSPoint();
+ pt2 = NSPoint();
+ pt1.x = x1;
+ pt1.y = y1;
+ pt2.x = x2;
+ pt2.y = y2;
+ this.color1 = color1.handle;
+ this.color2 = color2.handle;
+ this.alpha1 = alpha1;
+ this.alpha2 = alpha2;
NSColor start = NSColor.colorWithDeviceRed(cast(CGFloat) color1.handle[0], cast(CGFloat) color1.handle[1], cast(CGFloat) color1.handle[2], cast(CGFloat) (alpha1 / 255f));
NSColor end = NSColor.colorWithDeviceRed(cast(CGFloat) color2.handle[0], cast(CGFloat) color2.handle[1], cast(CGFloat) color2.handle[2], cast(CGFloat) (alpha2 / 255f));
gradient = (cast(NSGradient)(new NSGradient()).alloc()).initWithStartingColor(start, end);
init_();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
void destroy() {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Point.d
--- a/dwt/graphics/Point.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Point.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Point;
@@ -41,6 +41,7 @@
*
*
* @see Rectangle
+ * @see Sample code and further information
*/
public final class Point : SerializableCompatibility {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/RGB.d
--- a/dwt/graphics/RGB.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/RGB.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.RGB;
@@ -41,6 +41,8 @@
*
*
* @see Color
+ * @see Color and RGB snippets
+ * @see Sample code and further information
*/
public final class RGB : SerializableCompatibility {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Rectangle.d
--- a/dwt/graphics/Rectangle.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Rectangle.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -9,10 +9,11 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Rectangle;
+
import dwt.DWT;
import dwt.internal.SerializableCompatibility;
@@ -45,6 +46,7 @@
*
*
* @see Point
+ * @see Sample code and further information
*/
public final class Rectangle : SerializableCompatibility {
@@ -126,7 +128,7 @@
* @return true
if the rectangle contains the point and false
otherwise
*/
public bool contains (int x, int y) {
- return (x >= this.x) && (y >= this.y) && ((x - this.x) < width) && ((y - this.y) < height);
+ return (x >= this.x) && (y >= this.y) && x < (this.x + width) && y < (this.y + height);
}
/**
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Region.d
--- a/dwt/graphics/Region.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Region.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Region;
@@ -17,10 +17,13 @@
import dwt.DWT;
import dwt.DWTError;
import dwt.DWTException;
+import dwt.internal.C;
import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSAutoreleasePool;
import dwt.internal.cocoa.NSBezierPath;
import dwt.internal.cocoa.NSPoint;
import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSThread;
import dwt.internal.cocoa.OS;
import tango.text.convert.Format;
@@ -43,6 +46,9 @@
* method to release the operating system resources managed by each instance
* when those instances are no longer required.
*
+ *
+ * @see DWT Example: GraphicsExample
+ * @see Sample code and further information
*/
public final class Region : Resource {
@@ -92,9 +98,15 @@
*/
public this(Device device) {
super(device);
- handle = OS.NewRgn();
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ handle = OS.NewRgn();
if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
init_();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
this(Device device, QuickdrawTypes.RgnHandle handle) {
@@ -102,6 +114,78 @@
this.handle = handle;
}
+public static Region cocoa_new(Device device, int handle) {
+ return new Region(device, handle);
+}
+
+static int /*long*/ polyToRgn(int[] poly, int length) {
+ short[] r = new short[4];
+ int /*long*/ polyRgn = OS.NewRgn(), rectRgn = OS.NewRgn();
+ int minY = poly[1], maxY = poly[1];
+ for (int y = 3; y < length; y += 2) {
+ if (poly[y] < minY) minY = poly[y];
+ if (poly[y] > maxY) maxY = poly[y];
+ }
+ int[] inter = new int[length + 1];
+ for (int y = minY; y <= maxY; y++) {
+ int count = 0;
+ int x1 = poly[0], y1 = poly[1];
+ for (int p = 2; p < length; p += 2) {
+ int x2 = poly[p], y2 = poly[p + 1];
+ if (y1 !is y2 && ((y1 <= y && y < y2) || (y2 <= y && y < y1))) {
+ inter[count++] = (int)((((y - y1) / (float)(y2 - y1)) * (x2 - x1)) + x1 + 0.5f);
+ }
+ x1 = x2;
+ y1 = y2;
+ }
+ int x2 = poly[0], y2 = poly[1];
+ if (y1 !is y2 && ((y1 <= y && y < y2) || (y2 <= y && y < y1))) {
+ inter[count++] = (int)((((y - y1) / (float)(y2 - y1)) * (x2 - x1)) + x1 + 0.5f);
+ }
+ for (int gap=count/2; gap>0; gap/=2) {
+ for (int i=gap; i=0; j-=gap) {
+ if ((inter[j] - inter[j + gap]) <= 0)
+ break;
+ int temp = inter[j];
+ inter[j] = inter[j + gap];
+ inter[j + gap] = temp;
+ }
+ }
+ }
+ for (int i = 0; i < count; i += 2) {
+ OS.SetRect(r, (short)inter[i], (short)y, (short)(inter[i + 1]),(short)(y + 1));
+ OS.RectRgn(rectRgn, r);
+ OS.UnionRgn(polyRgn, rectRgn, polyRgn);
+ }
+ }
+ OS.DisposeRgn(rectRgn);
+ return polyRgn;
+}
+
+static int /*long*/ polyRgn(int[] pointArray, int count) {
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ int /*long*/ polyRgn;
+ if (C.PTR_SIZEOF is 4) {
+ polyRgn = OS.NewRgn();
+ OS.OpenRgn();
+ OS.MoveTo((short)pointArray[0], (short)pointArray[1]);
+ for (int i = 1; i < count / 2; i++) {
+ OS.LineTo((short)pointArray[2 * i], (short)pointArray[2 * i + 1]);
+ }
+ OS.LineTo((short)pointArray[0], (short)pointArray[1]);
+ OS.CloseRgn(polyRgn);
+ } else {
+ polyRgn = polyToRgn(pointArray, count);
+ }
+ return polyRgn;
+ } finally {
+ if (pool !is null) pool.release();
+ }
+}
+
/**
* Adds the given polygon to the collection of polygons
* the receiver maintains to describe its area.
@@ -121,21 +205,26 @@
public void add (int[] pointArray) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- add(pointArray, pointArray.length);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ add(pointArray, pointArray.length);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
void add(int[] pointArray, int count) {
if (count <= 2) return;
- QuickdrawTypes.RgnHandle polyRgn = OS.NewRgn();
- OS.OpenRgn();
- OS.MoveTo(cast(short)pointArray[0], cast(short)pointArray[1]);
- for (int i = 1; i < count / 2; i++) {
- OS.LineTo(cast(short)pointArray[2 * i], cast(short)pointArray[2 * i + 1]);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ int /*long*/ polyRgn = polyRgn(pointArray, count);
+ OS.UnionRgn(handle, polyRgn, handle);
+ OS.DisposeRgn(polyRgn);
+ } finally {
+ if (pool !is null) pool.release();
}
- OS.LineTo(cast(short)pointArray[0], cast(short)pointArray[1]);
- OS.CloseRgn(polyRgn);
- OS.UnionRgn(handle, polyRgn, handle);
- OS.DisposeRgn(polyRgn);
}
/**
@@ -156,7 +245,13 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (rect.width < 0 || rect.height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- add (rect.x, rect.y, rect.width, rect.height);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ add (rect.x, rect.y, rect.width, rect.height);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -180,12 +275,18 @@
public void add(int x, int y, int width, int height) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0 || height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- QuickdrawTypes.RgnHandle rectRgn = OS.NewRgn();
- Rect r;
- OS.SetRect(&r, cast(short)x, cast(short)y, cast(short)(x + width),cast(short)(y + height));
- OS.RectRgn(rectRgn, &r);
- OS.UnionRgn(handle, rectRgn, handle);
- OS.DisposeRgn(rectRgn);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ QuickdrawTypes.RgnHandle rectRgn = OS.NewRgn();
+ Rect r;
+ OS.SetRect(&r, cast(short)x, cast(short)y, cast(short)(x + width),cast(short)(y + height));
+ OS.RectRgn(rectRgn, &r);
+ OS.UnionRgn(handle, rectRgn, handle);
+ OS.DisposeRgn(rectRgn);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -207,7 +308,13 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (region is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (region.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- OS.UnionRgn(handle, region.handle, handle);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ OS.UnionRgn(handle, region.handle, handle);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -225,8 +332,14 @@
*/
public bool contains(int x, int y) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- QuickdrawTypes.Point point = {cast(short)x, cast(short)y};
- return OS.PtInRgn(point, handle);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ QuickdrawTypes.Point point = {cast(short)x, cast(short)y};
+ return OS.PtInRgn(point, handle);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -264,29 +377,30 @@
if (message is OS.kQDRegionToRectsMsgParse) {
Rect rect;
OS.memmove(&rect, r, rect.sizeof);
- NSPoint point = NSPoint();
- QuickdrawTypes.RgnHandle polyRgn = OS.NewRgn();
- OS.OpenRgn();
+ int i = 0;
+ NSPoint point = NSPoint();
+ int[] points = new int[10];
point.x = rect.left;
point.y = rect.top;
point = transform.transformPoint(point);
short startX, startY;
- OS.MoveTo(startX = cast(short)point.x, startY = cast(short)point.y);
- point.x = rect.right;
+ points[i++] = startX = (short)point.x;
+ points[i++] = startY = (short)point.y;
point.y = rect.top;
point = transform.transformPoint(point);
- OS.LineTo(cast(short)Math.round(point.x), cast(short)point.y);
- point.x = rect.right;
+ points[i++] = (short)Math.round(point.x);
+ points[i++] = (short)point.y;
point.y = rect.bottom;
point = transform.transformPoint(point);
- OS.LineTo(cast(short)Math.round(point.x), cast(short)Math.round(point.y));
- point.x = rect.left;
+ points[i++] = (short)Math.round(point.x);
+ points[i++] = (short)Math.round(point.y);
point.y = rect.bottom;
point = transform.transformPoint(point);
- OS.LineTo(cast(short)point.x, cast(short)Math.round(point.y));
- OS.LineTo(startX, startY);
- OS.CloseRgn(polyRgn);
- OS.UnionRgn(cast(QuickdrawTypes.RgnHandle) newRgn, polyRgn, cast(QuickdrawTypes.RgnHandle) newRgn);
+ points[i++] = (short)point.x;
+ points[i++] = (short)Math.round(point.y);
+ points[i++] = startX;
+ points[i++] = startY;
+ int /*long*/ polyRgn = polyRgn(points, points.length);
OS.DisposeRgn(polyRgn);
}
return null;
@@ -331,11 +445,18 @@
*/
public Rectangle getBounds() {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+ NSAutoreleasePool pool = null;
Rect bounds;
+
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
OS.GetRegionBounds(handle, &bounds);
int width = bounds.right - bounds.left;
int height = bounds.bottom - bounds.left;
return new Rectangle(bounds.left, bounds.top, width, height);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
NSBezierPath getPath() {
@@ -348,28 +469,24 @@
static NSPoint pt = NSPoint();
static Rect rect;
-extern(C) private static OSStatus* regionToRects(ushort message, QuickdrawTypes.RgnHandle rgn, Rect* r, void* path) {
+extern(C) private static OSStatus* regionToRects(ushort message, QuickdrawTypes.RgnHandle rgn, Rect* r, objc.id path) {
if (message is OS.kQDRegionToRectsMsgParse) {
OS.memmove(&rect, r, rect.sizeof);
pt.x = rect.left;
pt.y = rect.top;
- OS.objc_msgSend(cast(objc.id) path, OS.sel_moveToPoint_1, pt);
+ OS.objc_msgSend(path, OS.sel_moveToPoint_, pt);
pt.x = rect.right;
- OS.objc_msgSend(cast(objc.id) path, OS.sel_lineToPoint_1, pt);
+ OS.objc_msgSend(path, OS.sel_lineToPoint_, pt);
pt.x = rect.right;
pt.y = rect.bottom;
- OS.objc_msgSend(cast(objc.id) path, OS.sel_lineToPoint_1, pt);
+ OS.objc_msgSend(path, OS.sel_lineToPoint_, pt);
pt.x = rect.left;
- OS.objc_msgSend(cast(objc.id) path, OS.sel_lineToPoint_1, pt);
- OS.objc_msgSend(cast(objc.id) path, OS.sel_closePath);
+ OS.objc_msgSend(path, OS.sel_lineToPoint_, pt);
+ OS.objc_msgSend(path, OS.sel_closePath);
}
return null;
}
-public static Region carbon_new(Device device, QuickdrawTypes.RgnHandle handle) {
- return new Region(device, handle);
-}
-
/**
* Returns an integer hash code for the receiver. Any two
* objects that return true
when passed to
@@ -429,12 +546,18 @@
public void intersect(int x, int y, int width, int height) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0 || height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- QuickdrawTypes.RgnHandle rectRgn = OS.NewRgn();
- Rect r;
- OS.SetRect(&r, cast(short)x, cast(short)y, cast(short)(x + width),cast(short)(y + height));
- OS.RectRgn(rectRgn, &r);
- OS.SectRgn(handle, rectRgn, handle);
- OS.DisposeRgn(rectRgn);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ QuickdrawTypes.RgnHandle rectRgn = OS.NewRgn();
+ Rect r;
+ OS.SetRect(&r, cast(short)x, cast(short)y, cast(short)(x + width),cast(short)(y + height));
+ OS.RectRgn(rectRgn, &r);
+ OS.SectRgn(handle, rectRgn, handle);
+ OS.DisposeRgn(rectRgn);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -458,7 +581,13 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (region is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (region.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- OS.SectRgn(handle, region.handle, handle);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ OS.SectRgn(handle, region.handle, handle);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -480,9 +609,15 @@
*/
public bool intersects (int x, int y, int width, int height) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- Rect r;
- OS.SetRect(&r, cast(short)x, cast(short)y, cast(short)(x + width),cast(short)(y + height));
- return OS.RectInRgn(&rect, handle);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ Rect r;
+ OS.SetRect(&r, cast(short)x, cast(short)y, cast(short)(x + width),cast(short)(y + height));
+ return OS.RectInRgn(&rect, handle);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -534,7 +669,13 @@
*/
public bool isEmpty() {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- return OS.EmptyRgn(handle);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ return OS.EmptyRgn(handle);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -556,16 +697,15 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (pointArray.length < 2) return;
- QuickdrawTypes.RgnHandle polyRgn = OS.NewRgn();
- OS.OpenRgn();
- OS.MoveTo(cast(short)pointArray[0], cast(short)pointArray[1]);
- for (int i = 1; i < pointArray.length / 2; i++) {
- OS.LineTo(cast(short)pointArray[2 * i], cast(short)pointArray[2 * i + 1]);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ int /*long*/ polyRgn = polyRgn(pointArray, pointArray.length);
+ OS.DiffRgn(handle, polyRgn, handle);
+ OS.DisposeRgn(polyRgn);
+ } finally {
+ if (pool !is null) pool.release();
}
- OS.LineTo(cast(short)pointArray[0], cast(short)pointArray[1]);
- OS.CloseRgn(polyRgn);
- OS.DiffRgn(handle, polyRgn, handle);
- OS.DisposeRgn(polyRgn);
}
/**
@@ -611,12 +751,18 @@
public void subtract(int x, int y, int width, int height) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0 || height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- QuickdrawTypes.RgnHandle rectRgn = OS.NewRgn();
- Rect r;
- OS.SetRect(&r, cast(short)x, cast(short)y, cast(short)(x + width),cast(short)(y + height));
- OS.RectRgn(rectRgn, &r);
- OS.DiffRgn(handle, rectRgn, handle);
- OS.DisposeRgn(rectRgn);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ int /*long*/ rectRgn = OS.NewRgn();
+ Rect r;
+ OS.SetRect(&r, cast(short)x, cast(short)y, cast(short)(x + width),cast(short)(y + height));
+ OS.RectRgn(rectRgn, &r);
+ OS.DiffRgn(handle, rectRgn, handle);
+ OS.DisposeRgn(rectRgn);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -640,7 +786,13 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (region is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (region.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- OS.DiffRgn(handle, region.handle, handle);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ OS.DiffRgn(handle, region.handle, handle);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -658,7 +810,13 @@
*/
public void translate (int x, int y) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- OS.OffsetRgn (handle, cast(short)x, cast(short)y);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ OS.OffsetRgn (handle, cast(short)x, cast(short)y);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -679,7 +837,13 @@
public void translate (Point pt) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (pt is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- translate (pt.x, pt.y);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ translate (pt.x, pt.y);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Resource.d
--- a/dwt/graphics/Resource.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Resource.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Resource;
@@ -37,6 +37,7 @@
*
* @see #dispose
* @see #isDisposed
+ * @see Sample code and further information
*
* @since 3.1
*/
@@ -47,7 +48,7 @@
*/
Device device;
-this() {
+public this() {
}
this(Device device) {
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/TextLayout.d
--- a/dwt/graphics/TextLayout.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/TextLayout.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,12 +9,16 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.TextLayout;
import dwt.DWT;
import dwt.DWTException;
+import dwt.internal.Compatibility;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSAutoreleasePool;
+import dwt.internal.cocoa.NSBezierPath;
import dwt.internal.cocoa.NSColor;
import dwt.internal.cocoa.NSFont;
import dwt.internal.cocoa.NSLayoutManager;
@@ -27,6 +31,8 @@
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSTextContainer;
import dwt.internal.cocoa.NSTextStorage;
+import dwt.internal.cocoa.NSTextTab;
+import dwt.internal.cocoa.NSThread;
import dwt.internal.cocoa.OS;
import tango.text.convert.Format;
@@ -61,7 +67,11 @@
* when those instances are no longer required.
*
*
- * @since 3.0
+ * @see TextLayout, TextStyle snippets
+ * @see DWT Example: CustomControlExample, StyledText tab
+ * @see Sample code and further information
+ *
+ * @since 3.0
*/
public final class TextLayout : Resource {
@@ -83,6 +93,8 @@
int[] lineOffsets;
NSRect[] lineBounds;
+
+ static final int UNDERLINE_THICK = 1 << 16;
static class StyleItem {
TextStyle style;
@@ -130,11 +142,34 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
}
+float[] computePolyline(int left, int top, int right, int bottom) {
+ int height = bottom - top; // can be any number
+ int width = 2 * height; // must be even
+ int peaks = Compatibility.ceil(right - left, width);
+ if (peaks is 0 && right - left > 2) {
+ peaks = 1;
+ }
+ int length = ((2 * peaks) + 1) * 2;
+ if (length < 0) return new float[0];
+
+ float[] coordinates = new float[length];
+ for (int i = 0; i < peaks; i++) {
+ int index = 4 * i;
+ coordinates[index] = left + (width * i);
+ coordinates[index+1] = bottom;
+ coordinates[index+2] = coordinates[index] + width / 2;
+ coordinates[index+3] = top;
+ }
+ coordinates[length-2] = left + (width * peaks);
+ coordinates[length-1] = bottom;
+ return coordinates;
+}
+
void computeRuns() {
if (textStorage !is null) return;
NSString str = NSString.stringWith(text);
textStorage = (cast(NSTextStorage)(new NSTextStorage()).alloc());
- textStorage.initWithString_(str);
+ textStorage.initWithString(str);
layoutManager = cast(NSLayoutManager)(new NSLayoutManager()).alloc().init();
textContainer = cast(NSTextContainer)(new NSTextContainer()).alloc();
NSSize size = NSSize();
@@ -148,7 +183,7 @@
Font defaultFont = font !is null ? font : device.systemFont;
NSRange range = NSRange();
range.length = str.length();
- textStorage.addAttribute(OS.NSFontAttributeName(), defaultFont.handle, range);
+ textStorage.addAttribute(OS.NSFontAttributeName, defaultFont.handle, range);
NSMutableParagraphStyle paragraph = cast(NSMutableParagraphStyle)(new NSMutableParagraphStyle()).alloc().init();
NSTextAlignment align_ = NSLeftTextAlignment;
@@ -166,13 +201,27 @@
paragraph.setAlignment(align_);
paragraph.setLineSpacing(spacing);
paragraph.setFirstLineHeadIndent(indent);
+ paragraph.setLineBreakMode(wrapWidth !is -1 ? OS.NSLineBreakByWordWrapping : OS.NSLineBreakByClipping);
+ paragraph.setTabStops(NSArray.array());
+ if (tabs !is null) {
+ int count = tabs.length;
+ for (int i = 0, pos = 0; i < count; i++) {
+ pos += tabs[i];
+ NSTextTab tab = (NSTextTab)new NSTextTab().alloc();
+ tab = tab.initWithType(OS.NSLeftTabStopType, pos);
+ paragraph.addTabStop(tab);
+ tab.release();
+ }
+ int width = count - 2 >= 0 ? tabs[count - 1] - tabs[count - 2] : tabs[count - 1];
+ paragraph.setDefaultTabInterval(width);
+ }
- //TODO tabs ascend descent wrap
+ //TODO ascend descent wrap
- textStorage.addAttribute(OS.NSParagraphStyleAttributeName(), paragraph, range);
+ textStorage.addAttribute(OS.NSParagraphStyleAttributeName, paragraph, range);
paragraph.release();
- int textLength = str.length();
+ int /*long*/ textLength = str.length();
for (int i = 0; i < styles.length - 1; i++) {
StyleItem run = styles[i];
if (run.style is null) continue;
@@ -181,12 +230,12 @@
range.length = translateOffset(styles[i + 1].start) - range.location;
Font font = style.font;
if (font !is null) {
- textStorage.addAttribute(OS.NSFontAttributeName(), font.handle, range);
+ textStorage.addAttribute(OS.NSFontAttributeName, font.handle, range);
}
Color foreground = style.foreground;
if (foreground !is null) {
NSColor color = NSColor.colorWithDeviceRed(foreground.handle[0], foreground.handle[1], foreground.handle[2], 1);
- textStorage.addAttribute(OS.NSForegroundColorAttributeName(), color, range);
+ textStorage.addAttribute(OS.NSForegroundColorAttributeName, color, range);
}
Color background = style.background;
if (background !is null) {
@@ -194,15 +243,14 @@
textStorage.addAttribute(OS.NSBackgroundColorAttributeName, color, range);
}
if (style.strikeout) {
- textStorage.addAttribute(OS.NSStrikethroughStyleAttributeName(), NSNumber.numberWithInt(OS.NSUnderlineStyleSingle), range);
+ textStorage.addAttribute(OS.NSStrikethroughStyleAttributeName, NSNumber.numberWithInt(OS.NSUnderlineStyleSingle), range);
Color strikeColor = style.strikeoutColor;
if (strikeColor !is null) {
NSColor color = NSColor.colorWithDeviceRed(strikeColor.handle[0], strikeColor.handle[1], strikeColor.handle[2], 1);
- textStorage.addAttribute(OS.NSStrikethroughColorAttributeName(), color, range);
+ textStorage.addAttribute(OS.NSStrikethroughColorAttributeName, color, range);
}
}
if (style.underline) {
- //TODO - IME - thick
int underlineStyle = 0;
switch (style.underlineStyle) {
case DWT.UNDERLINE_SINGLE:
@@ -211,18 +259,21 @@
case DWT.UNDERLINE_DOUBLE:
underlineStyle = OS.NSUnderlineStyleDouble;
break;
+ case UNDERLINE_THICK:
+ underlineStyle = OS.NSUnderlineStyleThick;
+ break;
}
if (underlineStyle !is 0) {
- textStorage.addAttribute(OS.NSUnderlineStyleAttributeName(), NSNumber.numberWithInt(underlineStyle), range);
+ textStorage.addAttribute(OS.NSUnderlineStyleAttributeName, NSNumber.numberWithInt(underlineStyle), range);
Color underlineColor = style.underlineColor;
if (underlineColor !is null) {
NSColor color = NSColor.colorWithDeviceRed(underlineColor.handle[0], underlineColor.handle[1], underlineColor.handle[2], 1);
- textStorage.addAttribute(OS.NSUnderlineColorAttributeName(), color, range);
+ textStorage.addAttribute(OS.NSUnderlineColorAttributeName, color, range);
}
}
}
if (style.rise !is 0) {
- textStorage.addAttribute(OS.NSBaselineOffsetAttributeName(), NSNumber.numberWithInt(style.rise), range);
+ textStorage.addAttribute(OS.NSBaselineOffsetAttributeName, NSNumber.numberWithInt(style.rise), range);
}
if (style.metrics !is null) {
//TODO
@@ -233,11 +284,11 @@
textContainer.setLineFragmentPadding(0);
layoutManager.glyphRangeForTextContainer(textContainer);
- int numberOfLines, index, numberOfGlyphs = layoutManager.numberOfGlyphs();
+ int numberOfLines;
+ NSUInteger numberOfGlyphs = layoutManager.numberOfGlyphs(), index;
NSRangePointer rangePtr = cast(NSRangePointer) OS.malloc(NSRange.sizeof);
- NSRange lineRange = NSRange();
for (numberOfLines = 0, index = 0; index < numberOfGlyphs; numberOfLines++){
- layoutManager.lineFragmentUsedRectForGlyphAtIndex_effectiveRange_withoutAdditionalLayout_(index, rangePtr, true);
+ layoutManager.lineFragmentUsedRectForGlyphAtIndex(index, rangePtr, true);
OS.memmove(&lineRange, rangePtr, NSRange.sizeof);
index = lineRange.location + lineRange.length;
}
@@ -245,9 +296,10 @@
int[] offsets = new int[numberOfLines + 1];
NSRect[] bounds = new NSRect[numberOfLines];
for (numberOfLines = 0, index = 0; index < numberOfGlyphs; numberOfLines++){
- bounds[numberOfLines] = layoutManager.lineFragmentUsedRectForGlyphAtIndex_effectiveRange_withoutAdditionalLayout_(index, rangePtr, true);
+ bounds[numberOfLines] = layoutManager.lineFragmentUsedRectForGlyphAtIndex(index, rangePtr, true);
+ if (numberOfLines < bounds.length - 1) bounds[numberOfLines].height -= spacing;
OS.memmove(&lineRange, rangePtr, NSRange.sizeof);
- offsets[numberOfLines] = lineRange.location;
+ offsets[numberOfLines] = (int)/*64*/lineRange.location;
index = lineRange.location + lineRange.length;
}
if (numberOfLines is 0) {
@@ -257,7 +309,7 @@
bounds[0].height = Math.max(layoutManager.defaultLineHeightForFont(nsFont), ascent + descent);
}
OS.free(rangePtr);
- offsets[numberOfLines] = textStorage.length();
+ offsets[numberOfLines] = (int)/*64*/textStorage.length();
this.lineOffsets = offsets;
this.lineBounds = bounds;
}
@@ -345,32 +397,181 @@
if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
if (selectionForeground !is null && selectionForeground.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
if (selectionBackground !is null && selectionBackground.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- gc.checkGC(GC.CLIPPING | GC.TRANSFORM | GC.FOREGROUND);
-// float[] foreground = gc.data.foreground;
-// NSColor color = NSColor.colorWithDeviceRed(foreground[0], foreground[1], foreground[2], foreground[3]);
-// textStorage.setForegroundColor(color);
- NSPoint pt = NSPoint();
- pt.x = x;
- pt.y = y;
- NSRange range = NSRange();
- range.length = layoutManager.numberOfGlyphs();
- bool hasSelection = selectionStart <= selectionEnd && selectionStart !is -1 && selectionEnd !is -1;
+ int length = translateOffset(text.length());
+ if (length is 0 && flags is 0) return;
+ NSAutoreleasePool pool = gc.checkGC(GC.CLIPPING | GC.TRANSFORM | GC.FOREGROUND);
+ try {
+ gc.handle.saveGraphicsState();
+ float[] fg = gc.data.foreground;
+ NSColor foreground = NSColor.colorWithDeviceRed(fg[0], fg[1], fg[2], fg[3]);
+ NSPoint pt = NSPoint();
+ pt.x = x;
+ pt.y = y;
+ bool hasSelection = selectionStart <= selectionEnd && selectionStart !is -1 && selectionEnd !is -1;
NSRange* selectionRange = null;
- if (hasSelection) {
- selectionRange = new NSRange();
- selectionRange.location = selectionStart;
- selectionRange.length = selectionEnd - selectionStart + 1;
- if (selectionBackground is null) selectionBackground = device.getSystemColor(DWT.COLOR_LIST_SELECTION);
- NSColor selectionColor = NSColor.colorWithDeviceRed(selectionBackground.handle[0], selectionBackground.handle[1], selectionBackground.handle[2], selectionBackground.handle[3]);
+ NSColor selectionColor = null;
+ if (hasSelection || (flags & DWT.LAST_LINE_SELECTION) !is 0) {
+ if (selectionBackground is null) selectionBackground = device.getSystemColor(DWT.COLOR_LIST_SELECTION);
+ selectionColor = NSColor.colorWithDeviceRed(selectionBackground.handle[0], selectionBackground.handle[1], selectionBackground.handle[2], selectionBackground.handle[3]);
+ }
+ if (hasSelection) {
+ selectionRange = new NSRange();
+ selectionRange.location = selectionStart;
+ selectionRange.length = selectionEnd - selectionStart + 1;
layoutManager.addTemporaryAttribute(OS.NSBackgroundColorAttributeName, selectionColor, *selectionRange);
- }
- //TODO draw selection for flags (LAST_LINE_SELECTION and FULL_SELECTION)
- if (range.length > 0) {
- layoutManager.drawBackgroundForGlyphRange(range, pt);
- layoutManager.drawGlyphsForGlyphRange(range, pt);
- }
- if (selectionRange !is null) {
+ }
+ //TODO draw selection for flags (DELIMITER_SELECTION)
+ int numberOfGlyphs = layoutManager.numberOfGlyphs();
+ if (numberOfGlyphs > 0) {
+ NSRange range = new NSRange();
+ for (int i = 0; i < styles.length - 1; i++) {
+ StyleItem run = styles[i];
+ if (run.style !is null && run.style.foreground !is null) continue;
+ range.location = length !is 0 ? translateOffset(run.start) : 0;
+ range.length = translateOffset(styles[i + 1].start) - range.location;
+ layoutManager.addTemporaryAttribute(OS.NSForegroundColorAttributeName, foreground, range);
+ }
+ range.location = 0;
+ range.length = numberOfGlyphs;
+ layoutManager.drawBackgroundForGlyphRange(range, pt);
+ layoutManager.drawGlyphsForGlyphRange(range, pt);
+ range.length = length;
+ layoutManager.removeTemporaryAttribute(OS.NSForegroundColorAttributeName, range);
+ NSPoint point = new NSPoint();
+ for (int j = 0; j < styles.length; j++) {
+ StyleItem run = styles[j];
+ TextStyle style = run.style;
+ if (style is null) continue;
+ bool drawUnderline = style.underline && style.underlineStyle !is DWT.UNDERLINE_SINGLE && style.underlineStyle !is DWT.UNDERLINE_DOUBLE;
+ drawUnderline = drawUnderline && (j + 1 is styles.length || !style.isAdherentUnderline(styles[j + 1].style));
+ bool drawBorder = style.borderStyle !is DWT.NONE;
+ drawBorder = drawBorder && (j + 1 is styles.length || !style.isAdherentBorder(styles[j + 1].style));
+ if (!drawUnderline && !drawBorder) continue;
+ int end = j + 1 < styles.length ? translateOffset(styles[j + 1].start - 1) : length;
+ for (int i = 0; i < lineOffsets.length - 1; i++) {
+ int lineStart = untranslateOffset(lineOffsets[i]);
+ int lineEnd = untranslateOffset(lineOffsets[i + 1] - 1);
+ if (drawUnderline) {
+ int start = run.start;
+ for (int k = j; k > 0 && style.isAdherentUnderline(styles[k - 1].style); k--) {
+ start = styles[k - 1].start;
+ }
+ start = translateOffset(start);
+ if (!(start > lineEnd || end < lineStart)) {
+ range.location = layoutManager.glyphIndexForCharacterAtIndex(Math.max(lineStart, start));
+ range.length = layoutManager.glyphIndexForCharacterAtIndex(Math.min(lineEnd, end) + 1) - range.location;
+ if (range.length > 0) {
+ gc.handle.saveGraphicsState();
+ NSRect rect = layoutManager.boundingRectForGlyphRange(range, textContainer);
+ float baseline = layoutManager.typesetter().baselineOffsetInLayoutManager(layoutManager, lineStart);
+ float underlineX = pt.x + rect.x;
+ float underlineY = pt.y + rect.y + rect.height - baseline;
+ float[] color = null;
+ if (style.underlineColor !is null) color = style.underlineColor.handle;
+ if (color is null && style.foreground !is null) color = style.foreground.handle;
+ if (color !is null) {
+ NSColor.colorWithDeviceRed(color[0], color[1], color[2], color[3]).setStroke();
+ }
+ NSBezierPath path = NSBezierPath.bezierPath();
+ switch (style.underlineStyle) {
+ case DWT.UNDERLINE_ERROR: {
+ path.setLineWidth(2f);
+ path.setLineCapStyle(OS.NSRoundLineCapStyle);
+ path.setLineJoinStyle(OS.NSRoundLineJoinStyle);
+ path.setLineDash(new float[]{1, 3f}, 2, 0);
+ point.x = underlineX;
+ point.y = underlineY + 0.5f;
+ path.moveToPoint(point);
+ point.x = underlineX + rect.width;
+ point.y = underlineY + 0.5f;
+ path.lineToPoint(point);
+ break;
+ }
+ case DWT.UNDERLINE_SQUIGGLE: {
+ gc.handle.setShouldAntialias(false);
+ path.setLineWidth(1.0f);
+ path.setLineCapStyle(OS.NSButtLineCapStyle);
+ path.setLineJoinStyle(OS.NSMiterLineJoinStyle);
+ float lineBottom = pt.y + rect.y + rect.height;
+ float squigglyThickness = 1;
+ float squigglyHeight = 2 * squigglyThickness;
+ float squigglyY = Math.min(underlineY - squigglyHeight / 2, lineBottom - squigglyHeight - 1);
+ float[] points = computePolyline((int)underlineX, (int)squigglyY, (int)(underlineX + rect.width), (int)(squigglyY + squigglyHeight));
+ point.x = points[0] + 0.5f;
+ point.y = points[1] + 0.5f;
+ path.moveToPoint(point);
+ for (int p = 2; p < points.length; p+=2) {
+ point.x = points[p] + 0.5f;
+ point.y = points[p+1] + 0.5f;
+ path.lineToPoint(point);
+ }
+ break;
+ }
+ }
+ path.stroke();
+ gc.handle.restoreGraphicsState();
+ }
+ }
+ }
+ if (drawBorder) {
+ int start = run.start;
+ for (int k = j; k > 0 && style.isAdherentBorder(styles[k - 1].style); k--) {
+ start = styles[k - 1].start;
+ }
+ start = translateOffset(start);
+ if (!(start > lineEnd || end < lineStart)) {
+ range.location = layoutManager.glyphIndexForCharacterAtIndex(Math.max(lineStart, start));
+ range.length = layoutManager.glyphIndexForCharacterAtIndex(Math.min(lineEnd, end) + 1) - range.location;
+ if (range.length > 0) {
+ gc.handle.saveGraphicsState();
+ NSRect rect = layoutManager.boundingRectForGlyphRange(range, textContainer);
+ rect.x += pt.x + 0.5f;
+ rect.y += pt.y + 0.5f;
+ rect.width -= 0.5f;
+ rect.height -= 0.5f;
+ float[] color = null;
+ if (style.borderColor !is null) color = style.borderColor.handle;
+ if (color is null && style.foreground !is null) color = style.foreground.handle;
+ if (color !is null) {
+ NSColor.colorWithDeviceRed(color[0], color[1], color[2], color[3]).setStroke();
+ }
+ int width = 1;
+ float[] dashes = null;
+ switch (style.borderStyle) {
+ case DWT.BORDER_SOLID: break;
+ case DWT.BORDER_DASH: dashes = width !is 0 ? GC.LINE_DASH : GC.LINE_DASH_ZERO; break;
+ case DWT.BORDER_DOT: dashes = width !is 0 ? GC.LINE_DOT : GC.LINE_DOT_ZERO; break;
+ }
+ NSBezierPath path = NSBezierPath.bezierPath();
+ path.setLineDash(dashes, dashes !is null ? dashes.length : 0, 0);
+ path.appendBezierPathWithRect(rect);
+ path.stroke();
+ gc.handle.restoreGraphicsState();
+ }
+ }
+ }
+ }
+
+ }
+ }
+ if ((flags & DWT.LAST_LINE_SELECTION) !is 0) {
+ NSRect bounds = lineBounds[lineBounds.length - 1];
+ NSRect rect = new NSRect();
+ rect.x = pt.x + bounds.x + bounds.width;
+ rect.y = y + bounds.y;
+ rect.width = (flags & DWT.FULL_SELECTION) !is 0 ? 0x7fffffff : bounds.height / 3;
+ rect.height = bounds.height;
+ selectionColor.setFill();
+ NSBezierPath path = NSBezierPath.bezierPath();
+ path.appendBezierPathWithRect(rect);
+ path.fill();
+ }
+ if (selectionRange !is null) {
layoutManager.removeTemporaryAttribute(OS.NSBackgroundColorAttributeName, *selectionRange);
+ }
+ gc.handle.restoreGraphicsState();
+ } finally {
+ gc.uncheckGC(pool);
}
}
@@ -426,26 +627,37 @@
}
/**
- * Returns the bounds of the receiver.
+ * Returns the bounds of the receiver. The width returned is either the
+ * width of the longest line or the width set using {@link TextLayout#setWidth(int)}.
+ * To obtain the text bounds of a line use {@link TextLayout#getLineBounds(int)}.
*
* @return the bounds of the receiver
*
* @exception DWTException
* - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
*
+ *
+ * @see #setWidth(int)
+ * @see #getLineBounds(int)
*/
public Rectangle getBounds() {
checkLayout();
- computeRuns();
- NSRect rect = layoutManager.usedRectForTextContainer(textContainer);
- if (wrapWidth !is -1) rect.width = wrapWidth;
- if (text.length() is 0) {
- Font font = this.font !is null ? this.font : device.systemFont;
- NSFont nsFont = font.handle;
- rect.height = Math.max(rect.height, layoutManager.defaultLineHeightForFont(nsFont));
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ computeRuns();
+ NSRect rect = layoutManager.usedRectForTextContainer(textContainer);
+ if (wrapWidth !is -1) rect.width = wrapWidth;
+ if (text.length() is 0) {
+ Font font = this.font !is null ? this.font : device.systemFont;
+ NSFont nsFont = font.handle;
+ rect.height = Math.max(rect.height, layoutManager.defaultLineHeightForFont(nsFont));
+ }
+ rect.height = Math.max(rect.height, ascent + descent) + spacing;
+ return new Rectangle(0, 0, cast(int)rect.width, cast(int)rect.height);
+ } finally {
+ if (pool !is null) pool.release();
}
- rect.height = Math.max(rect.height, ascent + descent);
- return new Rectangle(0, 0, cast(int)rect.width, cast(int)rect.height);
}
/**
@@ -464,19 +676,25 @@
*/
public Rectangle getBounds(int start, int end) {
checkLayout();
- computeRuns();
- int length = text.length();
- if (length is 0) return new Rectangle(0, 0, 0, 0);
- if (start > end) return new Rectangle(0, 0, 0, 0);
- start = Math.min(Math.max(0, start), length - 1);
- end = Math.min(Math.max(0, end), length - 1);
- start = translateOffset(start);
- end = translateOffset(end);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ computeRuns();
+ int length = text.length();
+ if (length is 0) return new Rectangle(0, 0, 0, 0);
+ if (start > end) return new Rectangle(0, 0, 0, 0);
+ start = Math.min(Math.max(0, start), length - 1);
+ end = Math.min(Math.max(0, end), length - 1);
+ start = translateOffset(start);
+ end = translateOffset(end);
NSRange range = NSRange();
- range.location = layoutManager.glyphIndexForCharacterAtIndex(start);
- range.length = layoutManager.glyphIndexForCharacterAtIndex(end + 1) - range.location;
- NSRect rect = layoutManager.boundingRectForGlyphRange(range, textContainer);
+ range.location = layoutManager.glyphIndexForCharacterAtIndex(start);
+ range.length = layoutManager.glyphIndexForCharacterAtIndex(end + 1) - range.location;
+ NSRect rect = layoutManager.boundingRectForGlyphRange(range, textContainer);
return new Rectangle(cast(int)rect.x, cast(int)rect.y, cast(int)Math.ceil(rect.width), cast(int)Math.ceil(rect.height));
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -561,13 +779,19 @@
*/
public int getLevel(int offset) {
checkLayout();
- computeRuns();
- int length = text.length();
- if (!(0 <= offset && offset <= length)) DWT.error(DWT.ERROR_INVALID_RANGE);
- offset = translateOffset(offset);
- int level = 0;
- //TODO
- return level;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ computeRuns();
+ int length = text.length();
+ if (!(0 <= offset && offset <= length)) DWT.error(DWT.ERROR_INVALID_RANGE);
+ offset = translateOffset(offset);
+ int level = 0;
+ //TODO
+ return level;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -583,12 +807,18 @@
*/
public int[] getLineOffsets() {
checkLayout ();
- computeRuns();
- int[] offsets = new int[lineOffsets.length];
- for (int i = 0; i < offsets.length; i++) {
- offsets[i] = untranslateOffset(lineOffsets[i]);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ computeRuns();
+ int[] offsets = new int[lineOffsets.length];
+ for (int i = 0; i < offsets.length; i++) {
+ offsets[i] = untranslateOffset(lineOffsets[i]);
+ }
+ return offsets;
+ } finally {
+ if (pool !is null) pool.release();
}
- return offsets;
}
/**
@@ -607,16 +837,22 @@
*/
public int getLineIndex(int offset) {
checkLayout ();
- computeRuns();
- int length = text.length();
- if (!(0 <= offset && offset <= length)) DWT.error(DWT.ERROR_INVALID_RANGE);
- offset = translateOffset(offset);
- for (int line=0; line offset) {
- return line;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ computeRuns();
+ int length = text.length();
+ if (!(0 <= offset && offset <= length)) DWT.error(DWT.ERROR_INVALID_RANGE);
+ offset = translateOffset(offset);
+ for (int line=0; line offset) {
+ return line;
+ }
}
+ return lineBounds.length - 1;
+ } finally {
+ if (pool !is null) pool.release();
}
- return lineBounds.length - 1;
}
/**
@@ -634,10 +870,16 @@
*/
public Rectangle getLineBounds(int lineIndex) {
checkLayout();
- computeRuns();
- if (!(0 <= lineIndex && lineIndex < lineBounds.length)) DWT.error(DWT.ERROR_INVALID_RANGE);
- NSRect rect = lineBounds[lineIndex];
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ computeRuns();
+ if (!(0 <= lineIndex && lineIndex < lineBounds.length)) DWT.error(DWT.ERROR_INVALID_RANGE);
+ NSRect rect = lineBounds[lineIndex];
return new Rectangle(cast(int)rect.x, cast(int)rect.y, cast(int)rect.width, cast(int)rect.height);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -652,8 +894,14 @@
*/
public int getLineCount() {
checkLayout ();
- computeRuns();
- return lineOffsets.length - 1;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ computeRuns();
+ return lineOffsets.length - 1;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -671,22 +919,28 @@
*/
public FontMetrics getLineMetrics (int lineIndex) {
checkLayout ();
- computeRuns();
- int lineCount = getLineCount();
- if (!(0 <= lineIndex && lineIndex < lineCount)) DWT.error(DWT.ERROR_INVALID_RANGE);
- int length = text.length();
- if (length is 0) {
- Font font = this.font !is null ? this.font : device.systemFont;
- NSFont nsFont = font.handle;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ computeRuns();
+ int lineCount = getLineCount();
+ if (!(0 <= lineIndex && lineIndex < lineCount)) DWT.error(DWT.ERROR_INVALID_RANGE);
+ int length = text.length();
+ if (length is 0) {
+ Font font = this.font !is null ? this.font : device.systemFont;
+ NSFont nsFont = font.handle;
int ascent = cast(int)(0.5f + nsFont.ascender());
int descent = cast(int)(0.5f + (-nsFont.descender() + nsFont.leading()));
- ascent = Math.max(ascent, this.ascent);
- descent = Math.max(descent, this.descent);
- return FontMetrics.cocoa_new(ascent, descent, 0, 0, ascent + descent);
+ ascent = Math.max(ascent, this.ascent);
+ descent = Math.max(descent, this.descent);
+ return FontMetrics.cocoa_new(ascent, descent, 0, 0, ascent + descent);
+ }
+ Rectangle rect = getLineBounds(lineIndex);
+ int baseline = cast(int)layoutManager.typesetter().baselineOffsetInLayoutManager(layoutManager, getLineOffsets()[lineIndex]);
+ return FontMetrics.cocoa_new(rect.height - baseline, baseline, 0, 0, rect.height);
+ } finally {
+ if (pool !is null) pool.release();
}
- Rectangle rect = getLineBounds(lineIndex);
- int baseline = cast(int)layoutManager.typesetter().baselineOffsetInLayoutManager(layoutManager, getLineOffsets()[lineIndex]);
- return FontMetrics.cocoa_new(rect.height - baseline, baseline, 0, 0, rect.height);
}
/**
@@ -707,22 +961,28 @@
*/
public Point getLocation(int offset, bool trailing) {
checkLayout();
- computeRuns();
- int length = text.length();
- if (!(0 <= offset && offset <= length)) DWT.error(DWT.ERROR_INVALID_RANGE);
- if (length is 0) return new Point(0, 0);
- offset = translateOffset(offset);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ computeRuns();
+ int length = text.length();
+ if (!(0 <= offset && offset <= length)) DWT.error(DWT.ERROR_INVALID_RANGE);
+ if (length is 0) return new Point(0, 0);
+ offset = translateOffset(offset);
NSUInteger glyphIndex = layoutManager.glyphIndexForCharacterAtIndex(offset);
NSRect rect = layoutManager.lineFragmentUsedRectForGlyphAtIndex_effectiveRange_(glyphIndex, null);
- NSPoint point = layoutManager.locationForGlyphAtIndex(glyphIndex);
- if (trailing) {
+ NSPoint point = layoutManager.locationForGlyphAtIndex(glyphIndex);
+ if (trailing) {
NSRange range = NSRange();
- range.location = glyphIndex;
- range.length = 1;
- NSRect bounds = layoutManager.boundingRectForGlyphRange(range, textContainer);
- point.x += bounds.width;
+ range.location = glyphIndex;
+ range.length = 1;
+ NSRect bounds = layoutManager.boundingRectForGlyphRange(range, textContainer);
+ point.x += bounds.width;
+ }
+ return new Point(cast(int)point.x, cast(int)rect.y);
+ } finally {
+ if (pool !is null) pool.release();
}
- return new Point(cast(int)point.x, cast(int)rect.y);
}
/**
@@ -745,7 +1005,13 @@
* @see #getPreviousOffset(int, int)
*/
public int getNextOffset (int offset, int movement) {
- return _getOffset(offset, movement, true);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ return _getOffset(offset, movement, true);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
int _getOffset (int offset, int movement, bool forward) {
@@ -763,18 +1029,18 @@
} else {
offset--;
}
- return untranslateOffset(offset);
+ return Math.max(0, Math.min(length, untranslateOffset(offset)));
}
case DWT.MOVEMENT_WORD: {
- return untranslateOffset(textStorage.nextWordFromIndex(offset, forward));
+ return untranslateOffset((int)/*64*/textStorage.nextWordFromIndex(offset, forward));
}
case DWT.MOVEMENT_WORD_END: {
NSRange range = textStorage.doubleClickAtIndex(length is offset ? length - 1 : offset);
- return untranslateOffset(range.location + range.length);
+ return untranslateOffset((int)/*64*/(range.location + range.length));
}
case DWT.MOVEMENT_WORD_START: {
NSRange range = textStorage.doubleClickAtIndex(length is offset ? length - 1 : offset);
- return untranslateOffset(range.location);
+ return untranslateOffset((int)/*64*/range.location);
}
default:
break;
@@ -807,9 +1073,15 @@
*/
public int getOffset(Point point, int[] trailing) {
checkLayout();
- computeRuns();
- if (point is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- return getOffset(point.x, point.y, trailing);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ computeRuns();
+ if (point is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ return getOffset(point.x, point.y, trailing);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -837,18 +1109,24 @@
*/
public int getOffset(int x, int y, int[] trailing) {
checkLayout();
- computeRuns();
- if (trailing !is null && trailing.length < 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- int length = text.length();
- if (length is 0) return 0;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ computeRuns();
+ if (trailing !is null && trailing.length < 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+ int length = text.length();
+ if (length is 0) return 0;
NSPoint pt = NSPoint();
- pt.x = x;
- pt.y = y;
+ pt.x = x;
+ pt.y = y;
CGFloat partialFration;
- NSUInteger glyphIndex = layoutManager.glyphIndexForPoint_inTextContainer_fractionOfDistanceThroughGlyph_(pt, textContainer, &partialFration);
- int offset = layoutManager.characterIndexForGlyphAtIndex(glyphIndex);
+ NSUInteger glyphIndex = layoutManager.glyphIndexForPoint(pt, textContainer, &partialFration);
+ int /*long*/ offset = layoutManager.characterIndexForGlyphAtIndex(glyphIndex);
if (trailing !is null) trailing[0] = cast(int) Math.round(partialFration);
- return Math.min(untranslateOffset(offset), length - 1);
+ return Math.min(untranslateOffset((int)/*64*/offset), length - 1);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -885,7 +1163,13 @@
* @see #getNextOffset(int, int)
*/
public int getPreviousOffset (int index, int movement) {
- return _getOffset(index, movement, false);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ return _getOffset(index, movement, false);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -1088,8 +1372,14 @@
if ((alignment & DWT.LEFT) !is 0) alignment = DWT.LEFT;
if ((alignment & DWT.RIGHT) !is 0) alignment = DWT.RIGHT;
if (this.alignment is alignment) return;
- freeRuns();
- this.alignment = alignment;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ freeRuns();
+ this.alignment = alignment;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -1114,8 +1404,14 @@
checkLayout ();
if (ascent < -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
if (this.ascent is ascent) return;
- freeRuns();
- this.ascent = ascent;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ freeRuns();
+ this.ascent = ascent;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -1140,8 +1436,14 @@
checkLayout ();
if (descent < -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
if (this.descent is descent) return;
- freeRuns();
- this.descent = descent;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ freeRuns();
+ this.descent = descent;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -1167,7 +1469,13 @@
if (oldFont is font) return;
this.font = font;
if (oldFont !is null && oldFont.equals(font)) return;
- freeRuns();
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ freeRuns();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -1186,8 +1494,14 @@
checkLayout ();
if (indent < 0) return;
if (this.indent is indent) return;
- freeRuns();
- this.indent = indent;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ freeRuns();
+ this.indent = indent;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -1205,8 +1519,14 @@
public void setJustify (bool justify) {
checkLayout ();
if (justify is this.justify) return;
- freeRuns();
- this.justify = justify;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ freeRuns();
+ this.justify = justify;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -1227,7 +1547,13 @@
if ((orientation & DWT.LEFT_TO_RIGHT) !is 0) orientation = DWT.LEFT_TO_RIGHT;
if (this.orientation is orientation) return;
this.orientation = orientation;
- freeRuns();
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ freeRuns();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -1260,8 +1586,14 @@
if (i is segments.length) return;
}
}
- freeRuns();
- this.segments = segments;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ freeRuns();
+ this.segments = segments;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -1281,8 +1613,14 @@
checkLayout();
if (spacing < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
if (this.spacing is spacing) return;
- freeRuns();
- this.spacing = spacing;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ freeRuns();
+ this.spacing = spacing;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -1300,73 +1638,79 @@
*/
public void setStyle (TextStyle style, int start, int end) {
checkLayout();
- int length = text.length();
- if (length is 0) return;
- if (start > end) return;
- start = Math.min(Math.max(0, start), length - 1);
- end = Math.min(Math.max(0, end), length - 1);
- int low = -1;
- int high = styles.length;
- while (high - low > 1) {
- int index = (high + low) / 2;
- if (styles[index + 1].start > start) {
- high = index;
- } else {
- low = index;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ int length = text.length();
+ if (length is 0) return;
+ if (start > end) return;
+ start = Math.min(Math.max(0, start), length - 1);
+ end = Math.min(Math.max(0, end), length - 1);
+ int low = -1;
+ int high = styles.length;
+ while (high - low > 1) {
+ int index = (high + low) / 2;
+ if (styles[index + 1].start > start) {
+ high = index;
+ } else {
+ low = index;
+ }
}
- }
- if (0 <= high && high < styles.length) {
- StyleItem item = styles[high];
- if (item.start is start && styles[high + 1].start - 1 is end) {
- if (style is null) {
- if (item.style is null) return;
- } else {
- if (style.equals(item.style)) return;
+ if (0 <= high && high < styles.length) {
+ StyleItem item = styles[high];
+ if (item.start is start && styles[high + 1].start - 1 is end) {
+ if (style is null) {
+ if (item.style is null) return;
+ } else {
+ if (style.equals(item.style)) return;
+ }
}
}
- }
- freeRuns();
- int modifyStart = high;
- int modifyEnd = modifyStart;
- while (modifyEnd < styles.length) {
- if (styles[modifyEnd + 1].start > end) break;
- modifyEnd++;
- }
- if (modifyStart is modifyEnd) {
- int styleStart = styles[modifyStart].start;
- int styleEnd = styles[modifyEnd + 1].start - 1;
- if (styleStart is start && styleEnd is end) {
- styles[modifyStart].style = style;
- return;
+ freeRuns();
+ int modifyStart = high;
+ int modifyEnd = modifyStart;
+ while (modifyEnd < styles.length) {
+ if (styles[modifyEnd + 1].start > end) break;
+ modifyEnd++;
}
- if (styleStart !is start && styleEnd !is end) {
- StyleItem[] newStyles = new StyleItem[styles.length + 2];
- System.arraycopy(styles, 0, newStyles, 0, modifyStart + 1);
- StyleItem item = new StyleItem();
- item.start = start;
- item.style = style;
- newStyles[modifyStart + 1] = item;
- item = new StyleItem();
- item.start = end + 1;
- item.style = styles[modifyStart].style;
- newStyles[modifyStart + 2] = item;
- System.arraycopy(styles, modifyEnd + 1, newStyles, modifyEnd + 3, styles.length - modifyEnd - 1);
- styles = newStyles;
- return;
+ if (modifyStart is modifyEnd) {
+ int styleStart = styles[modifyStart].start;
+ int styleEnd = styles[modifyEnd + 1].start - 1;
+ if (styleStart is start && styleEnd is end) {
+ styles[modifyStart].style = style;
+ return;
+ }
+ if (styleStart !is start && styleEnd !is end) {
+ StyleItem[] newStyles = new StyleItem[styles.length + 2];
+ System.arraycopy(styles, 0, newStyles, 0, modifyStart + 1);
+ StyleItem item = new StyleItem();
+ item.start = start;
+ item.style = style;
+ newStyles[modifyStart + 1] = item;
+ item = new StyleItem();
+ item.start = end + 1;
+ item.style = styles[modifyStart].style;
+ newStyles[modifyStart + 2] = item;
+ System.arraycopy(styles, modifyEnd + 1, newStyles, modifyEnd + 3, styles.length - modifyEnd - 1);
+ styles = newStyles;
+ return;
+ }
}
+ if (start is styles[modifyStart].start) modifyStart--;
+ if (end is styles[modifyEnd + 1].start - 1) modifyEnd++;
+ int newLength = styles.length + 1 - (modifyEnd - modifyStart - 1);
+ StyleItem[] newStyles = new StyleItem[newLength];
+ System.arraycopy(styles, 0, newStyles, 0, modifyStart + 1);
+ StyleItem item = new StyleItem();
+ item.start = start;
+ item.style = style;
+ newStyles[modifyStart + 1] = item;
+ styles[modifyEnd].start = end + 1;
+ System.arraycopy(styles, modifyEnd, newStyles, modifyStart + 2, styles.length - modifyEnd);
+ styles = newStyles;
+ } finally {
+ if (pool !is null) pool.release();
}
- if (start is styles[modifyStart].start) modifyStart--;
- if (end is styles[modifyEnd + 1].start - 1) modifyEnd++;
- int newLength = styles.length + 1 - (modifyEnd - modifyStart - 1);
- StyleItem[] newStyles = new StyleItem[newLength];
- System.arraycopy(styles, 0, newStyles, 0, modifyStart + 1);
- StyleItem item = new StyleItem();
- item.start = start;
- item.style = style;
- newStyles[modifyStart + 1] = item;
- styles[modifyEnd].start = end + 1;
- System.arraycopy(styles, modifyEnd, newStyles, modifyStart + 2, styles.length - modifyEnd);
- styles = newStyles;
}
/**
@@ -1392,8 +1736,14 @@
if (i is tabs.length) return;
}
}
- freeRuns();
- this.tabs = tabs;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ freeRuns();
+ this.tabs = tabs;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -1412,12 +1762,18 @@
checkLayout ();
if (text is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (text.equals(this.text)) return;
- freeRuns();
- this.text = text;
- styles = new StyleItem[2];
- styles[0] = new StyleItem();
- styles[1] = new StyleItem();
- styles[styles.length - 1].start = text.length();
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ freeRuns();
+ this.text = text;
+ styles = new StyleItem[2];
+ styles[0] = new StyleItem();
+ styles[1] = new StyleItem();
+ styles[styles.length - 1].start = text.length();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -1440,8 +1796,14 @@
checkLayout();
if (width < -1 || width is 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
if (this.wrapWidth is width) return;
- freeRuns();
- this.wrapWidth = width;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ freeRuns();
+ this.wrapWidth = width;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/TextStyle.d
--- a/dwt/graphics/TextStyle.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/TextStyle.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.TextStyle;
@@ -38,6 +38,8 @@
* @see TextLayout
* @see Font
* @see Color
+ * @see TextLayout, TextStyle snippets
+ * @see Sample code and further information
*
* @since 3.0
*/
@@ -163,7 +165,7 @@
public this (Font font, Color foreground, Color background) {
if (font !is null && font.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT);
if (foreground !is null && foreground.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT);
- if (background !is null && background.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+ if (background !is null && background.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT);
this.font = font;
this.foreground = foreground;
this.background = background;
@@ -173,7 +175,7 @@
/**
* Create a new text style from an existing text style.
*
- *@param style the style to copy
+ * @param style the style to copy
*
* @since 3.4
*/
@@ -251,7 +253,7 @@
public hash_t toHash() {
hash_t hash = 0;
if (foreground !is null) hash ^= foreground.hashCode();
- if (background !is null) hash ^= background.hashCode();
+ if (background !is null) hash ^= background.hashCode();
if (font !is null) hash ^= font.hashCode();
if (metrics !is null) hash ^= metrics.hashCode();
if (underline) hash ^= hash;
@@ -272,7 +274,12 @@
if (borderStyle !is style.borderStyle) return false;
if (borderColor !is null) {
if (!borderColor.equals(style.borderColor)) return false;
- } else if (style.borderColor !is null) return false;
+ } else {
+ if (style.borderColor !is null) return false;
+ if (foreground !is null) {
+ if (!foreground.equals(style.foreground)) return false;
+ } else if (style.foreground !is null) return false;
+ }
return true;
}
@@ -283,7 +290,12 @@
if (underlineStyle !is style.underlineStyle) return false;
if (underlineColor !is null) {
if (!underlineColor.equals(style.underlineColor)) return false;
- } else if (style.underlineColor !is null) return false;
+ } else {
+ if (style.underlineColor !is null) return false;
+ if (foreground !is null) {
+ if (!foreground.equals(style.foreground)) return false;
+ } else if (style.foreground !is null) return false;
+ }
return true;
}
@@ -293,7 +305,12 @@
if (strikeout !is style.strikeout) return false;
if (strikeoutColor !is null) {
if (!strikeoutColor.equals(style.strikeoutColor)) return false;
- } else if (style.strikeoutColor !is null) return false;
+ } else {
+ if (style.strikeoutColor !is null) return false;
+ if (foreground !is null) {
+ if (!foreground.equals(style.foreground)) return false;
+ } else if (style.foreground !is null) return false;
+ }
return true;
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/graphics/Transform.d
--- a/dwt/graphics/Transform.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/graphics/Transform.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.graphics.Transform;
@@ -18,7 +18,9 @@
import dwt.DWTException;
import dwt.internal.cocoa.NSAffineTransform;
import dwt.internal.cocoa.NSAffineTransformStruct;
+import dwt.internal.cocoa.NSAutoreleasePool;
import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSThread;
import tango.text.convert.Format;
@@ -39,6 +41,9 @@
* which may not be available on some platforms.
*
*
+ * @see DWT Example: GraphicsExample
+ * @see Sample code and further information
+ *
* @since 3.1
*/
public class Transform : Resource {
@@ -143,11 +148,17 @@
*/
public this (Device device, float m11, float m12, float m21, float m22, float dx, float dy) {
super(device);
- handle = NSAffineTransform.transform();
- if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
- handle.retain();
- setElements(m11, m12, m21, m22, dx, dy);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ handle = NSAffineTransform.transform();
+ if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
+ handle.retain();
+ setElements(m11, m12, m21, m22, dx, dy);
init_();
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
static float[] checkTransform(float[] elements) {
@@ -179,25 +190,46 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (elements is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (elements.length < 6) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- NSAffineTransformStruct structt = handle.transformStruct();
- elements[0] = structt.m11;
- elements[1] = structt.m12;
- elements[2] = structt.m21;
- elements[3] = structt.m22;
- elements[4] = structt.tX;
- elements[5] = structt.tY;
-}
-
-public void identity() {
- if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSAffineTransformStruct structt = NSAffineTransformStruct();
- structt.m11 = 1;
- structt.m22 = 1;
- handle.setTransformStruct(structt);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ NSAffineTransformStruct struct_ = handle.transformStruct();
+ elements[0] = (float)/*64*/struct_.m11;
+ elements[1] = (float)/*64*/struct_.m12;
+ elements[2] = (float)/*64*/struct_.m21;
+ elements[3] = (float)/*64*/struct_.m22;
+ elements[4] = (float)/*64*/struct_.tX;
+ elements[5] = (float)/*64*/struct_.tY;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
* Modifies the receiver such that the matrix it represents becomes the
+ * identity matrix.
+ *
+ * @exception DWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @since 3.4
+ */
+public void identity() {
+ if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+ NSAutoreleasePool pool = null;
+ try {
+ NSAffineTransformStruct struct_ = NSAffineTransformStruct();
+ struct_.m11 = 1;
+ struct_.m22 = 1;
+ handle.setTransformStruct(structt);
+ } finally {
+ if (pool !is null) pool.release();
+ }
+}
+
+/**
+ * Modifies the receiver such that the matrix it represents becomes
* the mathematical inverse of the matrix it previously represented.
*
* @exception DWTException
@@ -207,11 +239,17 @@
*/
public void invert() {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSAffineTransformStruct structt = handle.transformStruct();
- if ((structt.m11 * structt.m22 - structt.m12 * structt.m21) is 0) {
- DWT.error(DWT.ERROR_CANNOT_INVERT_MATRIX);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ NSAffineTransformStruct struct_ = handle.transformStruct();
+ if ((struct_.m11 * struct_.m22 - struct_.m12 * struct_.m21) is 0) {
+ DWT.error(DWT.ERROR_CANNOT_INVERT_MATRIX);
+ }
+ handle.invert();
+ } finally {
+ if (pool !is null) pool.release();
}
- handle.invert();
}
/**
@@ -236,8 +274,14 @@
*/
public bool isIdentity() {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSAffineTransformStruct structt = handle.transformStruct();
- return structt.m11 is 1 && structt.m12 is 0 && structt.m21 is 0 && structt.m22 is 1 && structt.tX is 0 && structt.tY is 0;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ NSAffineTransformStruct struct = handle.transformStruct();
+ return struct.m11 is 1 && struct.m12 is 0 && struct.m21 is 0 && struct.m22 is 1 && struct.tX is 0 && struct.tY is 0;
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -259,7 +303,13 @@
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (matrix is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (matrix.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- handle.prependTransform(matrix.handle);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ handle.prependTransform(matrix.handle);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -277,7 +327,13 @@
*/
public void rotate(float angle) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- handle.rotateByDegrees(angle);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ handle.rotateByDegrees(angle);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -293,7 +349,13 @@
*/
public void scale(float scaleX, float scaleY) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- handle.scaleXBy(scaleX, scaleY);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ handle.scaleXBy(scaleX, scaleY);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -313,26 +375,51 @@
*/
public void setElements(float m11, float m12, float m21, float m22, float dx, float dy) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSAffineTransformStruct structt = NSAffineTransformStruct();
- structt.m11 = m11;
- structt.m12 = m12;
- structt.m21 = m21;
- structt.m22 = m22;
- structt.tX = dx;
- structt.tY = dy;
- handle.setTransformStruct(structt);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ NSAffineTransformStruct struct_ = NSAffineTransformStruct();
+ struct_.m11 = m11;
+ struct_.m12 = m12;
+ struct_.m21 = m21;
+ struct_.m22 = m22;
+ struct_.tX = dx;
+ struct_.tY = dy;
+ handle.setTransformStruct(struct_);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
+/**
+ * Modifies the receiver so that it represents a transformation that is
+ * equivalent to its previous transformation sheared by (shearX, shearY).
+ *
+ * @param shearX the shear factor in the X direction
+ * @param shearY the shear factor in the Y direction
+ *
+ * @exception DWTException
+ * - ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
+ *
+ *
+ * @since 3.4
+ */
public void shear(float shearX, float shearY) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- NSAffineTransformStruct structt = NSAffineTransformStruct();
- structt.m11 = 1;
- structt.m12 = shearX;
- structt.m21 = shearY;
- structt.m22 = 1;
- NSAffineTransform matrix = NSAffineTransform.transform();
- matrix.setTransformStruct(structt);
- handle.prependTransform(matrix);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ NSAffineTransformStruct struct_ = NSAffineTransformStruct();
+ struct_.m11 = 1;
+ struct_.m12 = shearX;
+ struct_.m21 = shearY;
+ struct_.m22 = 1;
+ NSAffineTransform matrix = NSAffineTransform.transform();
+ matrix.setTransformStruct(struct_);
+ handle.prependTransform(matrix);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
@@ -352,14 +439,20 @@
public void transform(float[] pointArray) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- NSPoint point = NSPoint();
- size_t length = pointArray.length / 2;
- for (int i = 0, j = 0; i < length; i++, j += 2) {
- point.x = pointArray[j];
- point.y = pointArray[j + 1];
- point = handle.transformPoint(point);
- pointArray[j] = point.x;
- pointArray[j + 1] = point.y;
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
+ try {
+ NSPoint point = NSPoint();
+ size_t length = pointArray.length / 2;
+ for (size_t i = 0, j = 0; i < length; i++, j += 2) {
+ point.x = pointArray[j];
+ point.y = pointArray[j + 1];
+ point = handle.transformPoint(point);
+ pointArray[j] = (float)/*64*/point.x;
+ pointArray[j + 1] = (float)/*64*/point.y;
+ }
+ } finally {
+ if (pool !is null) pool.release();
}
}
@@ -376,7 +469,13 @@
*/
public void translate(float offsetX, float offsetY) {
if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
- handle.translateXBy(offsetX, offsetY);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ handle.translateXBy(offsetX, offsetY);
+ } finally {
+ if (pool !is null) pool.release();
+ }
}
/**
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/BidiUtil.d
--- a/dwt/internal/BidiUtil.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/BidiUtil.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
+/*******************************************************************************
+ * 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
* which accompanies this distribution, and is available at
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.BidiUtil;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/C.d
--- a/dwt/internal/C.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/C.d Mon Dec 01 17:07:00 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.C;
@@ -32,7 +32,9 @@
public static const size_t PTR_SIZEOF = (void*).sizeof;
+/** @param ptr cast=(void *) */
alias stdlib.free free;
+/** @param env cast=(const char *) */
alias stdlib.getenv getenv;
alias stdlib.malloc malloc;
alias stdcstring.memset memset;
@@ -40,26 +42,115 @@
alias stdcstring.strlen strlen;
/+public static final native void free (int /*long*/ ptr);
-public static final native int /*long*/ getenv (byte[] wcsToMbcs);
public static final native int /*long*/ malloc (int /*long*/ size);
+/**
+ * @param dest cast=(void *)
+ * @param src cast=(const void *),flags=no_out critical
+ * @param size cast=(size_t)
+ */
public static final native void memmove (int /*long*/ dest, byte[] src, int /*long*/ size);
+/**
+ * @param dest cast=(void *)
+ * @param src cast=(const void *),flags=no_out critical
+ * @param size cast=(size_t)
+ */
public static final native void memmove (int /*long*/ dest, char[] src, int /*long*/ size);
+/**
+ * @param dest cast=(void *)
+ * @param src cast=(const void *),flags=no_out critical
+ * @param size cast=(size_t)
+ */
public static final native void memmove (int /*long*/ dest, double[] src, int /*long*/ size);
+/**
+ * @param dest cast=(void *)
+ * @param src cast=(const void *),flags=no_out critical
+ * @param size cast=(size_t)
+ */
public static final native void memmove (int /*long*/ dest, float[] src, int /*long*/ size);
+/**
+ * @param dest cast=(void *)
+ * @param src cast=(const void *),flags=no_out critical
+ * @param size cast=(size_t)
+ */
public static final native void memmove (int /*long*/ dest, int[] src, int /*long*/ size);
+/**
+ * @param dest cast=(void *)
+ * @param src cast=(const void *),flags=no_out critical
+ * @param size cast=(size_t)
+ */
public static final native void memmove (int /*long*/ dest, long[] src, int /*long*/ size);
+/**
+ * @param dest cast=(void *)
+ * @param src cast=(const void *),flags=no_out critical
+ * @param size cast=(size_t)
+ */
public static final native void memmove (int /*long*/ dest, short[] src, int /*long*/ size);
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *),flags=no_out critical
+ * @param size cast=(size_t)
+ */
public static final native void memmove (byte[] dest, char[] src, int /*long*/ size);
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
public static final native void memmove (byte[] dest, int /*long*/ src, int /*long*/ size);
+/**
+ * @param dest cast=(void *)
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
public static final native void memmove (int /*long*/ dest, int /*long*/ src, int /*long*/ size);
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
public static final native void memmove (char[] dest, int /*long*/ src, int /*long*/ size);
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
public static final native void memmove (double[] dest, int /*long*/ src, int /*long*/ size);
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
public static final native void memmove (float[] dest, int /*long*/ src, int /*long*/ size);
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
public static final native void memmove (int[] dest, byte[] src, int /*long*/ size);
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
public static final native void memmove (short[] dest, int /*long*/ src, int /*long*/ size);
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
public static final native void memmove (int[] dest, int /*long*/ src, int /*long*/ size);
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
public static final native void memmove (long[] dest, int /*long*/ src, int /*long*/ size);
+/**
+ * @param buffer cast=(void *),flags=critical
+ * @param num cast=(size_t)
+ */
public static final native int /*long*/ memset (int /*long*/ buffer, int c, int /*long*/ num);
public static final native int PTR_sizeof ();
+/** @param s cast=(char *) */
public static final native int strlen (int /*long*/ s);+/
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/CloneableCompatibility.d
--- a/dwt/internal/CloneableCompatibility.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/CloneableCompatibility.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2000, 2003 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.CloneableCompatibility;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/Compatibility.d
--- a/dwt/internal/Compatibility.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/Compatibility.d Mon Dec 01 17:07:00 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
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/DWTEventListener.d
--- a/dwt/internal/DWTEventListener.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/DWTEventListener.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.DWTEventListener;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/DWTEventObject.d
--- a/dwt/internal/DWTEventObject.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/DWTEventObject.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.DWTEventObject;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/LONG.d
--- a/dwt/internal/LONG.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/LONG.d Mon Dec 01 17:07:00 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
@@ -14,6 +14,7 @@
import dwt.dwthelper.utils;
+/** @jniclass flags=no_gen */
public class LONG
{
public int /*long*/value;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/Library.d
--- a/dwt/internal/Library.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/Library.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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
@@ -38,7 +38,7 @@
/**
* DWT Minor version number (must be in the range 0..999)
*/
- static const int MINOR_VERSION = 440;
+ static int MINOR_VERSION = 514;
/**
* DWT revision number (must be >= 0)
@@ -132,10 +132,12 @@
FileOutputStream os = null;
InputStream is = null;
File file = new File(fileName);
+ bool extracted = false;
try {
if (!file.exists ()) {
is = Library.class.getResourceAsStream ("/" + mappedName); //$NON-NLS-1$
if (is !is null) {
+ extracted = true;
int read;
byte [] buffer = new byte [4096];
os = new FileOutputStream (fileName);
@@ -152,6 +154,7 @@
if (load (fileName)) return true;
}
}
+ if (load (fileName)) return true;
} catch (Throwable e) {
try {
if (os !is null) os.close ();
@@ -159,8 +162,8 @@
try {
if (is !is null) is.close ();
} catch (IOException e1) {}
+ if (extracted && file.exists ()) file.delete ();
}
- if (file.exists ()) file.delete ();
return false;
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/Lock.d
--- a/dwt/internal/Lock.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/Lock.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -21,12 +21,11 @@
import dwt.dwthelper.utils;
/**
- * Instance of this represent a recursive monitor.
+ * Instances of this represent a recursive monitor. Note that this
+ * is an empty implementation which does not actually perform locking.
*/
public class Lock
{
- int count, waitCount;
- Thread owner;
Mutex mutex;
Condition cond;
@@ -59,7 +58,6 @@
}
catch (SyncException e)
{
- /* Wait forever, just like synchronized blocks */
}
}
--waitCount;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/Platform.d
--- a/dwt/internal/Platform.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/Platform.d Mon Dec 01 17:07:00 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.Platform;
@@ -18,5 +18,5 @@
public class Platform {
public static const String PLATFORM = "cocoa"; //$NON-NLS-1$
-
+public static final Lock lock = new Lock ();
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/SerializableCompatibility.d
--- a/dwt/internal/SerializableCompatibility.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/SerializableCompatibility.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.SerializableCompatibility;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/c/Carbon.d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/c/Carbon.d Mon Dec 01 17:07:00 2008 +0100
@@ -0,0 +1,334 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Nov 18, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ *
+ */
+module dwt.internal.c.Carbon;
+
+import dwt.dwthelper.utils;
+import bindings = dwt.internal.c.bindings;
+
+// MacTypes.h
+
+/********************************************************************************
+
+ Base integer types for all target OS's and CPU's
+
+ UInt8 8-bit unsigned integer
+ SInt8 8-bit signed integer
+ UInt16 16-bit uinteger
+ SInt16 16-bit signed integer
+ UInt32 32-bit uinteger
+ SInt32 32-bit signed integer
+ UInt64 64-bit uinteger
+ SInt64 64-bit integer
+
+ *********************************************************************************/
+alias ubyte UInt8;
+alias byte SInt8;
+alias ushort UInt16;
+alias short SInt16;
+alias uint UInt32;
+alias int SInt32;
+alias ulong UInt64;
+alias long SInt64;
+
+alias byte uint8_t;
+
+/********************************************************************************
+
+ Higher level basic types
+
+ OSErr 16-bit result error code
+ OSStatus 32-bit result error code
+ LogicalAddress Address in the clients virtual address space
+ ConstLogicalAddress Address in the clients virtual address space that will only be read
+ PhysicalAddress Real address as used on the hardware bus
+ BytePtr Pointer to an array of bytes
+ ByteCount The size of an array of bytes
+ ByteOffset An offset into an array of bytes
+ ItemCount 32-bit iteration count
+ OptionBits Standard 32-bit set of bit flags
+ PBVersion ?
+ Duration 32-bit millisecond timer for drivers
+ AbsoluteTime 64-bit clock
+ ScriptCode A particular set of written characters (e.g. Roman vs Cyrillic) and their encoding
+ LangCode A particular language (e.g. English), as represented using a particular ScriptCode
+ RegionCode Designates a language as used in a particular region (e.g. British vs American
+ English) together with other region-dependent characteristics (e.g. date format)
+ FourCharCode A 32-bit value made by packing four 1 byte characters together
+ OSType A FourCharCode used in the OS and file system (e.g. creator)
+ ResType A FourCharCode used to tag resources (e.g. 'DLOG')
+
+ *********************************************************************************/
+alias SInt16 OSErr;
+alias SInt32 OSStatus;
+alias void* LogicalAddress;
+alias /*const*/void* ConstLogicalAddress;
+alias void* PhysicalAddress;
+alias UInt8* BytePtr;
+alias uint ByteCount;
+alias uint ByteOffset;
+alias SInt32 Duration;
+alias UnsignedWide AbsoluteTime;
+alias UInt32 OptionBits;
+alias uint ItemCount;
+alias UInt32 PBVersion;
+alias SInt16 ScriptCode;
+alias SInt16 LangCode;
+alias SInt16 RegionCode;
+alias UInt32 FourCharCode;
+alias FourCharCode OSType;
+alias FourCharCode ResType;
+alias OSType* OSTypePtr;
+alias ResType* ResTypePtr;
+
+struct UnsignedWide
+{
+ uint hi;
+ uint lo;
+}
+
+struct ProcessSerialNumber
+{
+ uint highLongOfPSN;
+ uint lowLongOfPSN;
+}
+
+struct CPSProcessSerNum
+{
+ uint lo;
+ uint hi;
+}
+
+alias ProcessSerialNumber * ProcessSerialNumberPtr;
+
+
+
+// Appearance.h
+enum ThemeCursor : uint
+{
+ kThemeArrowCursor = 0,
+ kThemeCopyArrowCursor = 1,
+ kThemeAliasArrowCursor = 2,
+ kThemeContextualMenuArrowCursor = 3,
+ kThemeIBeamCursor = 4,
+ kThemeCrossCursor = 5,
+ kThemePlusCursor = 6,
+ kThemeWatchCursor = 7,
+ kThemeClosedHandCursor = 8,
+ kThemeOpenHandCursor = 9,
+ kThemePointingHandCursor = 10,
+ kThemeCountingUpHandCursor = 11,
+ kThemeCountingDownHandCursor = 12,
+ kThemeCountingUpAndDownHandCursor = 13,
+ kThemeSpinningCursor = 14,
+ kThemeResizeLeftCursor = 15,
+ kThemeResizeRightCursor = 16,
+ kThemeResizeLeftRightCursor = 17,
+ kThemeNotAllowedCursor = 18,
+ kThemeResizeUpCursor = 19,
+ kThemeResizeDownCursor = 20,
+ kThemeResizeUpDownCursor = 21,
+ kThemePoofCursor = 22
+}
+
+alias bindings.SetThemeCursor SetThemeCursor;
+
+
+
+// CABase.h
+static if ((void*).sizeof > int.sizeof) // 64bit target
+ alias double CGFloat;
+
+else
+ alias float CGFloat;
+
+
+
+// CarbonEventsCore.h
+alias bindings.GetCurrentButtonState GetCurrentButtonState;
+
+
+
+// CFBase.h
+alias void* CFTypeRef;
+alias void* __CFAllocator;
+alias __CFAllocator* CFAllocatorRef;
+alias void* __CFString;
+alias __CFString* CFStringRef;
+
+alias bindings.CFRelease CFRelease;
+
+
+
+// CFNumberFormatter.h
+enum
+{
+ kCFNumberFormatterPadBeforePrefix = 0,
+ kCFNumberFormatterPadAfterPrefix = 1,
+ kCFNumberFormatterPadBeforeSuffix = 2,
+ kCFNumberFormatterPadAfterSuffix = 3
+}
+
+enum CFNumberFormatterRoundingMode
+{
+ kCFNumberFormatterRoundCeiling = 0,
+ kCFNumberFormatterRoundFloor = 1,
+ kCFNumberFormatterRoundDown = 2,
+ kCFNumberFormatterRoundUp = 3,
+ kCFNumberFormatterRoundHalfEven = 4,
+ kCFNumberFormatterRoundHalfDown = 5,
+ kCFNumberFormatterRoundHalfUp = 6
+}
+
+enum
+{
+ kCFNumberFormatterNoStyle = 0,
+ kCFNumberFormatterDecimalStyle = 1,
+ kCFNumberFormatterCurrencyStyle = 2,
+ kCFNumberFormatterPercentStyle = 3,
+ kCFNumberFormatterScientificStyle = 4,
+ kCFNumberFormatterSpellOutStyle = 5
+}
+
+
+
+//CFPropertyList.h
+enum CFPropertyListFormat
+{
+ kCFPropertyListOpenStepFormat = 1,
+ kCFPropertyListXMLFormat_v1_0 = 100,
+ kCFPropertyListBinaryFormat_v1_0 = 200
+}
+
+enum CFPropertyListMutabilityOptions
+{
+ kCFPropertyListImmutable = 0,
+ kCFPropertyListMutableContainers = 1,
+ kCFPropertyListMutableContainersAndLeaves = 2
+}
+
+
+
+// CFRunLoop.h
+alias void* __CFRunLoop;
+alias __CFRunLoop* CFRunLoopRef;
+
+
+
+// CFString.h
+alias uint CFStringEncoding;
+
+
+
+// CFURL.h
+alias bindings.CFURLCreateStringByAddingPercentEscapes CFURLCreateStringByAddingPercentEscapes;
+
+
+
+// CGColorSpace.h
+alias void* CGColorSpace;
+alias CGColorSpace* CGColorSpaceRef;
+
+
+
+// CGError.h
+alias int CGError;
+
+
+
+// CGEventTypes.h
+alias void* __CGEvent;
+alias __CGEvent* CGEventRef;
+
+
+
+// CGRemoteOperation.h
+alias bindings.CGWarpMouseCursorPosition CGWarpMouseCursorPosition;
+
+
+
+// Gestalt.h
+alias bindings.Gestalt Gestalt;
+
+
+
+// IconsCore.h
+alias void* OpaqueIconRef;
+alias OpaqueIconRef* IconRef;
+
+
+
+// Processes.h
+enum ProcessApplicationTransformState : uint
+{
+ kProcessTransformToForegroundApplication = 1
+}
+
+alias bindings.GetCurrentProcess GetCurrentProcess;
+alias bindings.SetFrontProcess SetFrontProcess;
+alias bindings.TransformProcessType TransformProcessType;
+
+short CPSSetProcessName (CPSProcessSerNum* PSN, String processname)
+{
+ return bindings.CPSSetProcessName(PSN, processname.ptr);
+}
+
+
+
+// Quickdraw.h
+struct Rect
+{
+ short top;
+ short left;
+ short bottom;
+ short right;
+}
+
+alias int QDRegionParseDirection;
+alias extern (C) OSStatus function (ushort message, RgnHandle rgn, /*const*/ Rect* rect, void* refCon) RegionToRectsProcPtr;
+alias RegionToRectsProcPtr RegionToRectsUPP;
+
+alias bindings.NewRgn NewRgn;
+alias bindings.RectRgn RectRgn;
+alias bindings.OpenRgn OpenRgn;
+alias bindings.OffsetRgn OffsetRgn;
+alias bindings.MoveTo MoveTo;
+alias bindings.LineTo LineTo;
+alias bindings.UnionRgn UnionRgn;
+alias bindings.CloseRgn CloseRgn;
+alias bindings.DisposeRgn DisposeRgn;
+alias bindings.PtInRgn PtInRgn;
+alias bindings.GetRegionBounds GetRegionBounds;
+alias bindings.SectRgn SectRgn;
+alias bindings.EmptyRgn EmptyRgn;
+alias bindings.DiffRgn DiffRgn;
+alias bindings.RectInRgn RectInRgn;
+alias bindings.QDRegionToRects QDRegionToRects;
+alias bindings.CopyRgn CopyRgn;
+alias bindings.SetRect SetRect;
+
+
+
+// QuickdrawTypes.h
+struct MacRegion
+{
+ ushort rgnSize; /* size in bytes; don't rely on it */
+ Rect rgnBBox; /* enclosing rectangle; in Carbon use GetRegionBounds */
+}
+
+struct Point
+{
+ short v;
+ short h;
+}
+
+alias MacRegion Region;
+alias MacRegion* RgnPtr;
+alias RgnPtr* RgnHandle;
+
+alias bool Boolean;
+alias bool BOOL;
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/c/bindings.d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/c/bindings.d Mon Dec 01 17:07:00 2008 +0100
@@ -0,0 +1,71 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Nov 18, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ *
+ */
+module dwt.internal.c.bindings;
+
+import dwt.internal.c.Carbon;
+public import dwt.internal.cocoa.CGPoint;
+
+extern (C):
+
+// Appearance.h
+int SetThemeCursor (ThemeCursor inCursor);
+
+
+
+// CarbonEventsCore.h
+uint GetCurrentButtonState ();
+
+
+
+// CFBase.h
+void CFRelease (CFTypeRef cf);
+
+
+
+// CFURL.h
+CFStringRef CFURLCreateStringByAddingPercentEscapes (CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding);
+
+
+
+// CGRemoteOperation.h
+CGError CGWarpMouseCursorPosition (CGPoint newCursorPosition);
+
+
+
+// Gestalt.h
+short Gestalt (uint selector, int* response);
+
+
+
+// Processes.h
+short CPSSetProcessName (CPSProcessSerNum* PSN, char* processname);
+short GetCurrentProcess (ProcessSerialNumber* PSN);
+short SetFrontProcess (/*const*/ ProcessSerialNumber* PSN);
+int TransformProcessType (/*const*/ ProcessSerialNumber* psn, ProcessApplicationTransformState transformState);
+
+
+
+// Quickdraw.h
+RgnHandle NewRgn ();
+void RectRgn (RgnHandle rgn, /*const*/Rect* r);
+void OpenRgn ();
+void OffsetRgn (RgnHandle rgn, short dh, short dv);
+void MoveTo (short h, short v);
+void LineTo (short h, short v);
+void UnionRgn (RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn);
+void CloseRgn (RgnHandle dstRgn);
+void DisposeRgn (RgnHandle rgn);
+Boolean PtInRgn (Point pt, RgnHandle rgn);
+Rect* GetRegionBounds (RgnHandle region, Rect* bounds);
+void SectRgn (RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn);
+Boolean EmptyRgn (RgnHandle rgn);
+void DiffRgn (RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn);
+Boolean RectInRgn (/*const*/Rect* r, RgnHandle rgn);
+OSStatus QDRegionToRects (RgnHandle rgn, QDRegionParseDirection dir, RegionToRectsUPP proc, void* userData);
+void CopyRgn (RgnHandle srcRgn, RgnHandle dstRgn);
+void SetRect (Rect* r, short left, short top, short right, short bottom);
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/c/carboncore/Gestalt.d
--- a/dwt/internal/c/carboncore/Gestalt.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: Aug 23, 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.c.carboncore.Gestalt;
-
-import bindings = dwt.internal.c.carboncore.bindings;
-
-alias bindings.Gestalt Gestalt;
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/c/carboncore/MacTypes.d
--- a/dwt/internal/c/carboncore/MacTypes.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.c.carboncore.MacTypes;
-
-/********************************************************************************
-
- Base integer types for all target OS's and CPU's
-
- UInt8 8-bit unsigned integer
- SInt8 8-bit signed integer
- UInt16 16-bit uinteger
- SInt16 16-bit signed integer
- UInt32 32-bit uinteger
- SInt32 32-bit signed integer
- UInt64 64-bit uinteger
- SInt64 64-bit integer
-
- *********************************************************************************/
-alias ubyte UInt8;
-alias byte SInt8;
-alias ushort UInt16;
-alias short SInt16;
-alias uint UInt32;
-alias int SInt32;
-alias ulong UInt64;
-alias long SInt64;
-
-alias byte uint8_t;
-
-/********************************************************************************
-
- Higher level basic types
-
- OSErr 16-bit result error code
- OSStatus 32-bit result error code
- LogicalAddress Address in the clients virtual address space
- ConstLogicalAddress Address in the clients virtual address space that will only be read
- PhysicalAddress Real address as used on the hardware bus
- BytePtr Pointer to an array of bytes
- ByteCount The size of an array of bytes
- ByteOffset An offset into an array of bytes
- ItemCount 32-bit iteration count
- OptionBits Standard 32-bit set of bit flags
- PBVersion ?
- Duration 32-bit millisecond timer for drivers
- AbsoluteTime 64-bit clock
- ScriptCode A particular set of written characters (e.g. Roman vs Cyrillic) and their encoding
- LangCode A particular language (e.g. English), as represented using a particular ScriptCode
- RegionCode Designates a language as used in a particular region (e.g. British vs American
- English) together with other region-dependent characteristics (e.g. date format)
- FourCharCode A 32-bit value made by packing four 1 byte characters together
- OSType A FourCharCode used in the OS and file system (e.g. creator)
- ResType A FourCharCode used to tag resources (e.g. 'DLOG')
-
- *********************************************************************************/
-alias SInt16 OSErr;
-alias SInt32 OSStatus;
-alias void* LogicalAddress;
-alias /*const*/void* ConstLogicalAddress;
-alias void* PhysicalAddress;
-alias UInt8* BytePtr;
-alias uint ByteCount;
-alias uint ByteOffset;
-alias SInt32 Duration;
-alias UnsignedWide AbsoluteTime;
-alias UInt32 OptionBits;
-alias uint ItemCount;
-alias UInt32 PBVersion;
-alias SInt16 ScriptCode;
-alias SInt16 LangCode;
-alias SInt16 RegionCode;
-alias UInt32 FourCharCode;
-alias FourCharCode OSType;
-alias FourCharCode ResType;
-alias OSType* OSTypePtr;
-alias ResType* ResTypePtr;
-
-struct UnsignedWide
-{
- uint hi;
- uint lo;
-}
-
-struct ProcessSerialNumber
-{
- uint highLongOfPSN;
- uint lowLongOfPSN;
-}
-
-alias ProcessSerialNumber * ProcessSerialNumberPtr;
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/c/carboncore/bindings.d
--- a/dwt/internal/c/carboncore/bindings.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: Aug 23, 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.c.carboncore.bindings;
-
-extern (C):
-
-short Gestalt (uint selector, int* response);
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/c/custom.d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/c/custom.d Mon Dec 01 17:07:00 2008 +0100
@@ -0,0 +1,302 @@
+module dwt.internal.c.custom;
+
+import tango.stdc.stdlib;
+
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.objc.cocoa.Cocoa;
+import dwt.internal.objc.runtime;
+
+extern (C):
+
+static IMP drawRect_1CALLBACK;
+
+static void drawRect(id obj, SEL sel, NSRect rect)
+{
+ return drawRect_1CALLBACK(obj, sel, &rect);
+}
+
+IMP drawRect_CALLBACK (IMP func)
+{
+ drawRect_1CALLBACK = func;
+ return cast(IMP) &drawRect;
+}
+
+
+
+static IMP drawInteriorWithFrame_1inView_1CALLBACK;
+
+static void drawInteriorWithFrame_1inView(id obj, SEL sel, NSRect rect, id view)
+{
+ return drawInteriorWithFrame_1inView_1CALLBACK(obj, sel, &rect, view);
+}
+
+IMP drawInteriorWithFrame_inView_CALLBACK (IMP func)
+{
+ drawInteriorWithFrame_1inView_1CALLBACK = func;
+ return cast(IMP) &drawInteriorWithFrame_1inView;
+}
+
+
+
+static IMP setFrame_1CALLBACK;
+
+static void setFrame(id obj, SEL sel, NSRect rect)
+{
+ return setFrame_1CALLBACK(obj, sel, &rect);
+}
+
+IMP setFrame_CALLBACK (IMP func)
+{
+ setFrame_1CALLBACK = func;
+ return cast(IMP) &setFrame;
+}
+
+
+
+static IMP setFrameOrigin_1CALLBACK;
+
+static void setFrameOrigin(id obj, SEL sel, NSPoint point)
+{
+ return setFrameOrigin_1CALLBACK(obj, sel, &point);
+}
+
+IMP setFrameOrigin_CALLBACK (IMP func)
+{
+ setFrameOrigin_1CALLBACK = func;
+ return cast(IMP) &setFrameOrigin;
+}
+
+
+
+static IMP setFrameSize_1CALLBACK;
+
+static void setFrameSize(id obj, SEL sel, NSSize size)
+{
+ return setFrameSize_1CALLBACK(obj, sel, &size);
+}
+
+IMP setFrameSize_CALLBACK (IMP func)
+{
+ setFrameSize_1CALLBACK = func;
+ return cast(IMP) &setFrameSize;
+}
+
+
+
+static IMP hitTest_1CALLBACK;
+
+static void hitTest(id obj, SEL sel, NSPoint point)
+{
+ return hitTest_1CALLBACK(obj, sel, &point);
+}
+
+IMP hitTest_CALLBACK (IMP func)
+{
+ hitTest_1CALLBACK = func;
+ return cast(IMP) &hitTest;
+}
+
+
+
+static IMP webView_1setFrame_1CALLBACK;
+
+static void webView_1setFrame(id obj, SEL sel, id sender, NSRect rect)
+{
+ return webView_1setFrame_1CALLBACK(obj, sel, sender, &rect);
+}
+
+IMP webView_setFrame_CALLBACK (IMP func)
+{
+ webView_1setFrame_1CALLBACK = func;
+ return cast(IMP) &webView_1setFrame;
+}
+
+
+
+
+static IMP markedRange_1CALLBACK;
+
+static NSRange markedRangeProc(id obj, SEL sel)
+{
+ NSRange* ptr = cast(NSRange*) markedRange_1CALLBACK(obj, sel);
+ NSRange range = *ptr;
+ free(ptr);
+ return range;
+}
+
+IMP markedRange_CALLBACK (IMP func)
+{
+ markedRange_1CALLBACK = func;
+ return cast(IMP) &markedRangeProc;
+}
+
+
+
+static IMP selectedRange_1CALLBACK;
+
+static NSRange selectedRangeProc(id obj, SEL sel)
+{
+ NSRange* ptr = cast(NSRange*) selectedRange_1CALLBACK(obj, sel);
+ NSRange range = *ptr;
+ free(ptr);
+ return range;
+}
+
+IMP selectedRange_CALLBACK (IMP func)
+{
+ selectedRange_1CALLBACK = func;
+ return cast(IMP) &selectedRangeProc;
+}
+
+
+
+static IMP highlightSelectionInClipRect_1CALLBACK;
+
+static void highlightSelectionInClipRect(id obj, SEL sel, NSRect rect)
+{
+ return highlightSelectionInClipRect_1CALLBACK(obj, sel, &rect);
+}
+
+IMP highlightSelectionInClipRect_CALLBACK (IMP func)
+{
+ highlightSelectionInClipRect_1CALLBACK = func;
+ return cast(IMP) &highlightSelectionInClipRect;
+}
+
+
+
+static IMP attributedSubstringFromRange_1CALLBACK;
+
+static id attributedSubstringFromRangeProc(id obj, SEL sel, NSRange arg0)
+{
+ return attributedSubstringFromRange_1CALLBACK(obj, sel, &arg0);
+}
+
+IMP attributedSubstringFromRange_CALLBACK (IMP func)
+{
+ attributedSubstringFromRange_1CALLBACK = func;
+ return cast(IMP) &attributedSubstringFromRangeProc;
+}
+
+
+
+static IMP setMarkedText_1selectedRange_1CALLBACK;
+
+static void setMarkedText_1selectedRange(id obj, SEL sel, id* arg0, NSRange arg1)
+{
+ setMarkedText_1selectedRange_1CALLBACK(obj, sel, arg0, &arg1);
+}
+
+IMP setMarkedText_selectedRange_CALLBACK (IMP func)
+{
+ setMarkedText_1selectedRange_1CALLBACK = func;
+ return cast(IMP) &setMarkedText_1selectedRange;
+}
+
+
+
+static IMP characterIndexForPoint_1CALLBACK;
+
+static int characterIndexForPoint(id obj, SEL sel, NSPoint point)
+{
+ return cast(int) characterIndexForPoint_1CALLBACK(obj, sel, &point);
+}
+
+IMP characterIndexForPoint_CALLBACK (IMP func)
+{
+ characterIndexForPoint_1CALLBACK = func;
+ return cast(IMP) &characterIndexForPoint;
+}
+
+
+
+static IMP firstRectForCharacterRange_1CALLBACK;
+
+static NSRect firstRectForCharacterRangeProc(id obj, SEL sel, NSRange arg0)
+{
+ NSRect* ptr = cast(NSRect*) firstRectForCharacterRange_1CALLBACK(obj, sel, &arg0);
+ NSRect result = *ptr;
+ free(ptr);
+ return result;
+}
+
+IMP firstRectForCharacterRange_CALLBACK (IMP func)
+{
+ firstRectForCharacterRange_1CALLBACK = func;
+ return cast(IMP) &firstRectForCharacterRangeProc;
+}
+
+
+
+static IMP textView_1willChangeSelectionFromCharacterRange_1toCharacterRange_1CALLBACK;
+
+static NSRange textView_1willChangeSelectionFromCharacterRange_1toCharacterRange(id obj, SEL sel, id aTextView, NSRange oldSelectedCharRange, NSRange newSelectedCharRange)
+{
+ NSRange* ptr = cast(NSRange*) textView_1willChangeSelectionFromCharacterRange_1toCharacterRange_1CALLBACK(obj, sel, aTextView, &oldSelectedCharRange, &newSelectedCharRange);
+ NSRange result = *ptr;
+ free(ptr);
+ return result;
+}
+
+IMP textView_willChangeSelectionFromCharacterRange_toCharacterRange_CALLBACK (IMP func)
+{
+ textView_1willChangeSelectionFromCharacterRange_1toCharacterRange_1CALLBACK = func;
+ return cast(IMP) &textView_1willChangeSelectionFromCharacterRange_1toCharacterRange;
+}
+
+
+
+// TODO
+IMP draggedImage_movedTo_CALLBACK (IMP func)
+{
+ return null;
+}
+
+
+
+// TODO
+IMP draggedImage_beganAt_CALLBACK (IMP func)
+{
+ return null;
+}
+
+
+
+static IMP draggedImage_1endedAt_1operation_1CALLBACK;
+
+static void draggedImage_1endedAt_1operation(id obj, SEL sel, id image, NSPoint point, NSDragOperation op)
+{
+ return draggedImage_1endedAt_1operation_1CALLBACK(obj, sel, image, &point, op);
+}
+
+IMP draggedImage_endedAt_operation_CALLBACK (IMP func)
+{
+ draggedImage_1endedAt_1operation_1CALLBACK = func;
+ return cast(IMP) &draggedImage_1endedAt_1operation;
+}
+
+
+
+static IMP accessibilityHitTest_1CALLBACK;
+
+static void accessibilityHitTest(id obj, SEL sel, NSPoint point)
+{
+ return accessibilityHitTest_1CALLBACK(obj, sel, &point);
+}
+
+IMP accessibilityHitTest_CALLBACK (IMP func)
+{
+ accessibilityHitTest_1CALLBACK = func;
+ return cast(IMP) &accessibilityHitTest;
+}
+
+
+
+// TODO
+IMP dragSelectionWithEvent_offset_slideBack_CALLBACK (IMP func)
+{
+ return null;
+}
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/c/gl.d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/c/gl.d Mon Dec 01 17:07:00 2008 +0100
@@ -0,0 +1,27 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 3, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ *
+ */
+module dwt.internal.c.gl;
+
+alias uint GLenum;
+alias ubyte GLboolean;
+alias uint GLbitfield;
+alias byte GLbyte;
+alias short GLshort;
+alias int GLint;
+alias int GLsizei;
+alias ubyte GLubyte;
+alias ushort GLushort;
+alias uint GLuint;
+alias float GLfloat;
+alias float GLclampf;
+alias double GLdouble;
+alias double GLclampd;
+alias void GLvoid;
+
+alias int GLintptr;
+alias int GLsizeiptr;
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/c/hiservices/Processes.d
--- a/dwt/internal/c/hiservices/Processes.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: Aug 23, 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.c.hiservices.Processes;
-
-import bindings = dwt.internal.c.hiservices.bindings;
-
-enum ProcessApplicationTransformState : uint
-{
- kProcessTransformToForegroundApplication = 1
-}
-
-alias ProcessApplicationTransformState.kProcessTransformToForegroundApplication kProcessTransformToForegroundApplication;
-
-alias bindings.GetCurrentProcess GetCurrentProcess;
-alias bindings.SetFrontProcess SetFrontProcess;
-alias bindings.TransformProcessType TransformProcessType;
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/c/hiservices/bindings.d
--- a/dwt/internal/c/hiservices/bindings.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: Aug 23, 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.c.hiservices.bindings;
-
-import dwt.internal.c.carboncore.MacTypes;
-import dwt.internal.c.hiservices.Processes;
-
-extern (C):
-short GetCurrentProcess (ProcessSerialNumber* PSN);
-short SetFrontProcess (/*const*/ ProcessSerialNumber* PSN);
-int TransformProcessType (/*const*/ ProcessSerialNumber* psn, ProcessApplicationTransformState transformState);
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/c/qd/Quickdraw.d
--- a/dwt/internal/c/qd/Quickdraw.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.c.qd.Quickdraw;
-
-import dwt.internal.c.qd.QuickdrawTypes;
-import dwt.internal.c.carboncore.MacTypes;
-
-import bindings = dwt.internal.c.qd.bindings;
-
-struct Rect
-{
- short top;
- short left;
- short bottom;
- short right;
-}
-
-alias int QDRegionParseDirection;
-
-//template Quickdraw ()
-//{
- alias bindings.RegionToRectsProcPtr RegionToRectsProcPtr;
-
- alias bindings.RegionToRectsUPP RegionToRectsUPP;
-
- alias bindings.NewRgn NewRgn;
- alias bindings.RectRgn RectRgn;
- alias bindings.OpenRgn OpenRgn;
- alias bindings.OffsetRgn OffsetRgn;
- alias bindings.MoveTo MoveTo;
- alias bindings.LineTo LineTo;
- alias bindings.UnionRgn UnionRgn;
- alias bindings.CloseRgn CloseRgn;
- alias bindings.DisposeRgn DisposeRgn;
- alias bindings.PtInRgn PtInRgn;
- alias bindings.GetRegionBounds GetRegionBounds;
- alias bindings.SectRgn SectRgn;
- alias bindings.EmptyRgn EmptyRgn;
- alias bindings.DiffRgn DiffRgn;
- alias bindings.RectInRgn RectInRgn;
- alias bindings.QDRegionToRects QDRegionToRects;
- alias bindings.CopyRgn CopyRgn;
- alias bindings.SetRect SetRect;
-//}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/c/qd/QuickdrawTypes.d
--- a/dwt/internal/c/qd/QuickdrawTypes.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.c.qd.QuickdrawTypes;
-
-import dwt.internal.c.qd.Quickdraw;
-
-struct MacRegion
-{
- ushort rgnSize; /* size in bytes; don't rely on it */
- Rect rgnBBox; /* enclosing rectangle; in Carbon use GetRegionBounds */
-}
-
-struct Point
-{
- short v;
- short h;
-}
-
-alias MacRegion Region;
-alias MacRegion* RgnPtr;
-alias RgnPtr* RgnHandle;
-
-alias bool Boolean;
-alias bool BOOL;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/c/qd/bindings.d
--- a/dwt/internal/c/qd/bindings.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.c.qd.bindings;
-
-import dwt.internal.c.carboncore.MacTypes;
-import dwt.internal.c.qd.QuickdrawTypes;
-import dwt.internal.c.qd.Quickdraw;
-import dwt.internal.objc.runtime;
-
-
-alias extern (C) OSStatus* function (UInt16 message, RgnHandle rgn, /*const*/Rect* rect, void* refCon) RegionToRectsProcPtr;
-alias RegionToRectsProcPtr RegionToRectsUPP;
-
-extern (C):
-
-RgnHandle NewRgn ();
-void RectRgn (RgnHandle rgn, /*const*/Rect* r);
-void OpenRgn ();
-void OffsetRgn (RgnHandle rgn, short dh, short dv);
-void MoveTo (short h, short v);
-void LineTo (short h, short v);
-void UnionRgn (RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn);
-void CloseRgn (RgnHandle dstRgn);
-void DisposeRgn (RgnHandle rgn);
-Boolean PtInRgn (Point pt, RgnHandle rgn);
-Rect* GetRegionBounds (RgnHandle region, Rect* bounds);
-void SectRgn (RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn);
-Boolean EmptyRgn (RgnHandle rgn);
-void DiffRgn (RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn);
-Boolean RectInRgn (/*const*/Rect* r, RgnHandle rgn);
-OSStatus QDRegionToRects (RgnHandle rgn, QDRegionParseDirection dir, RegionToRectsUPP proc, void* userData);
-void CopyRgn (RgnHandle srcRgn, RgnHandle dstRgn);
-void SetRect (Rect* r, short left, short top, short right, short bottom);
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/CFNumberFormatter.d
--- a/dwt/internal/cocoa/CFNumberFormatter.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: Jul 31, 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.cocoa.CFNumberFormatter;
-
-extern (C):
-
-enum {
- kCFNumberFormatterPadBeforePrefix = 0,
- kCFNumberFormatterPadAfterPrefix = 1,
- kCFNumberFormatterPadBeforeSuffix = 2,
- kCFNumberFormatterPadAfterSuffix = 3
-}
-
-enum CFNumberFormatterRoundingMode {
- kCFNumberFormatterRoundCeiling = 0,
- kCFNumberFormatterRoundFloor = 1,
- kCFNumberFormatterRoundDown = 2,
- kCFNumberFormatterRoundUp = 3,
- kCFNumberFormatterRoundHalfEven = 4,
- kCFNumberFormatterRoundHalfDown = 5,
- kCFNumberFormatterRoundHalfUp = 6
-}
-
-alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundCeiling kCFNumberFormatterRoundCeiling;
-alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundFloor kCFNumberFormatterRoundFloor;
-alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundDown kCFNumberFormatterRoundDown;
-alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundUp kCFNumberFormatterRoundUp;
-alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundHalfEven kCFNumberFormatterRoundHalfEven;
-alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundHalfDown kCFNumberFormatterRoundHalfDown;
-alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundHalfUp kCFNumberFormatterRoundHalfUp;
-
-enum {
- kCFNumberFormatterNoStyle = 0,
- kCFNumberFormatterDecimalStyle = 1,
- kCFNumberFormatterCurrencyStyle = 2,
- kCFNumberFormatterPercentStyle = 3,
- kCFNumberFormatterScientificStyle = 4,
- kCFNumberFormatterSpellOutStyle = 5
-}
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/CFPropertyList.d
--- a/dwt/internal/cocoa/CFPropertyList.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: Jul 28, 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.cocoa.CFPropertyList;
-
-extern (C):
-
-enum CFPropertyListFormat {
- kCFPropertyListOpenStepFormat = 1,
- kCFPropertyListXMLFormat_v1_0 = 100,
- kCFPropertyListBinaryFormat_v1_0 = 200
-}
-
-alias CFPropertyListFormat.kCFPropertyListOpenStepFormat kCFPropertyListOpenStepFormat;
-alias CFPropertyListFormat.kCFPropertyListXMLFormat_v1_0 kCFPropertyListXMLFormat_v1_0;
-alias CFPropertyListFormat.kCFPropertyListBinaryFormat_v1_0 kCFPropertyListBinaryFormat_v1_0;
-
-enum CFPropertyListMutabilityOptions {
- kCFPropertyListImmutable = 0,
- kCFPropertyListMutableContainers = 1,
- kCFPropertyListMutableContainersAndLeaves = 2
-}
-
-alias CFPropertyListMutabilityOptions.kCFPropertyListImmutable kCFPropertyListImmutable;
-alias CFPropertyListMutabilityOptions.kCFPropertyListMutableContainers kCFPropertyListMutableContainers;
-alias CFPropertyListMutabilityOptions.kCFPropertyListMutableContainersAndLeaves kCFPropertyListMutableContainersAndLeaves;
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/CFRunLoopRef.d
--- a/dwt/internal/cocoa/CFRunLoopRef.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: Aug 4, 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.cocoa.CFRunLoopRef;
-
-extern (C):
-
-alias void** CFRunLoopRef;
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/CGBase.d
--- a/dwt/internal/cocoa/CGBase.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: Jul 23, 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.cocoa.CGBase;
-
-extern (C):
-
-static if ((void*).sizeof > int.sizeof) // 64bit target
- alias double CGFloat;
-else
- alias float CGFloat;
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/CGColorSpace.d
--- a/dwt/internal/cocoa/CGColorSpace.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: Jul 26, 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.cocoa.CGColorSpace;
-
-alias void* CGColorSpace;
-alias CGColorSpace* CGColorSpaceRef;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/CGEventTypes.d
--- a/dwt/internal/cocoa/CGEventTypes.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: Jul 22, 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.cocoa.CGEventTypes;
-
-alias void* CGEventRef;
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/CGFloat.d
--- a/dwt/internal/cocoa/CGFloat.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: Jul 23, 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.cocoa.CGFloat;
-
-extern (C):
-
-static if ((void*).sizeof > int.sizeof) // 64bit target
- alias double CGFloat;
-
-else
- alias float CGFloat;
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/CGPoint.d
--- a/dwt/internal/cocoa/CGPoint.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/CGPoint.d Mon Dec 01 17:07:00 2008 +0100
@@ -9,13 +9,11 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.cocoa.CGPoint;
-import dwt.internal.cocoa.CGFloat;
-
-extern (C):
+import dwt.internal.c.Carbon;
struct CGPoint {
CGFloat x;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/CGRect.d
--- a/dwt/internal/cocoa/CGRect.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/CGRect.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.cocoa.CGRect;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/CGSize.d
--- a/dwt/internal/cocoa/CGSize.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/CGSize.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 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
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.cocoa.CGSize;
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/CIColor.d
--- a/dwt/internal/cocoa/CIColor.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.CIColor;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSColor;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class CIColor : NSObject
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public CIColor initWithColor (NSColor color)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithColor_1, color !is null ? color.id_ : null);
- return result !is null ? this : null;
- }
-}
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/CIImage.d
--- a/dwt/internal/cocoa/CIImage.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.CIImage;
-
-import dwt.internal.cocoa.CGFloat;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSBitmapImageRep;
-import dwt.internal.cocoa.NSImage : NSCompositingOperation;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSPoint;
-import dwt.internal.cocoa.NSRect;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class CIImage : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public void drawAtPoint (NSPoint point, NSRect fromRect, NSCompositingOperation op, CGFloat delta)
- {
- OS.objc_msgSend(this.id_, OS.sel_drawAtPoint_1fromRect_1operation_1fraction_1, point, fromRect, op, delta);
- }
-
- public void drawInRect (NSRect rect, NSRect fromRect, NSCompositingOperation op, CGFloat delta)
- {
- OS.objc_msgSend(this.id_, OS.sel_drawInRect_1fromRect_1operation_1fraction_1, rect, fromRect, op, delta);
- }
-
- public CIImage initWithBitmapImageRep (NSBitmapImageRep bitmapImageRep)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithBitmapImageRep_1, bitmapImageRep !is null ? bitmapImageRep.id_ : null);
- return result !is null ? this : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/DOMDocument.d
--- a/dwt/internal/cocoa/DOMDocument.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/DOMDocument.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,229 +1,42 @@
/*******************************************************************************
+ * 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
+ *
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.cocoa.DOMDocument;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
import dwt.internal.cocoa.WebFrame;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.objc : id;
+import objc = dwt.internal.objc.runtime;
public class DOMDocument : NSObject {
- public this () {
- super();
- }
-
- public this (objc.id id) {
- super(id);
- }
-
- // public NSURL URLWithAttributeString(NSString String) {
- // int result = OS.objc_msgSend(this.id, OS.sel_URLWithAttributeString_1, String !is null ? String.id : 0);
- // return result !is 0 ? new NSURL(result) : null;
- // }
-
- // public DOMNode adoptNode(DOMNode source) {
- // int result = OS.objc_msgSend(this.id, OS.sel_adoptNode_1, source !is null ? source.id : 0);
- // return result !is 0 ? new DOMNode(result) : null;
- // }
-
- // public DOMAttr createAttribute(NSString name) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createAttribute_1, name !is null ? name.id : 0);
- // return result !is 0 ? new DOMAttr(result) : null;
- // }
-
- // public DOMAttr createAttributeNS__(NSString createAttributeNS, NSString ) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createAttributeNS_1_1, createAttributeNS !is null ? createAttributeNS.id : 0, !is null ? .id : 0);
- // return result !is 0 ? new DOMAttr(result) : null;
- // }
-
- // public DOMAttr createAttributeNS_qualifiedName_(NSString namespaceURI, NSString qualifiedName) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createAttributeNS_1qualifiedName_1, namespaceURI !is null ? namespaceURI.id : 0, qualifiedName !is null ? qualifiedName.id : 0);
- // return result !is 0 ? new DOMAttr(result) : null;
- // }
-
- // public DOMCDATASection createCDATASection(NSString data) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createCDATASection_1, data !is null ? data.id : 0);
- // return result !is 0 ? new DOMCDATASection(result) : null;
- // }
-
- // public DOMCSSStyleDeclaration createCSSStyleDeclaration() {
- // int result = OS.objc_msgSend(this.id, OS.sel_createCSSStyleDeclaration);
- // return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
- // }
-
- // public DOMComment createComment(NSString data) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createComment_1, data !is null ? data.id : 0);
- // return result !is 0 ? new DOMComment(result) : null;
- // }
-
- // public DOMDocumentFragment createDocumentFragment() {
- // int result = OS.objc_msgSend(this.id, OS.sel_createDocumentFragment);
- // return result !is 0 ? new DOMDocumentFragment(result) : null;
- // }
+public this() {
+ super();
+}
- // public DOMElement createElement(NSString tagName) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createElement_1, tagName !is null ? tagName.id : 0);
- // return result !is 0 ? new DOMElement(result) : null;
- // }
-
- // public DOMElement createElementNS__(NSString createElementNS, NSString ) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createElementNS_1_1, createElementNS !is null ? createElementNS.id : 0, !is null ? .id : 0);
- // return result !is 0 ? new DOMElement(result) : null;
- // }
-
- // public DOMElement createElementNS_qualifiedName_(NSString namespaceURI, NSString qualifiedName) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createElementNS_1qualifiedName_1, namespaceURI !is null ? namespaceURI.id : 0, qualifiedName !is null ? qualifiedName.id : 0);
- // return result !is 0 ? new DOMElement(result) : null;
- // }
-
- // public DOMEntityReference createEntityReference(NSString name) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createEntityReference_1, name !is null ? name.id : 0);
- // return result !is 0 ? new DOMEntityReference(result) : null;
- // }
-
- // public DOMEvent createEvent(NSString eventType) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createEvent_1, eventType !is null ? eventType.id : 0);
- // return result !is 0 ? new DOMEvent(result) : null;
- // }
-
- // public DOMXPathExpression createExpression__(NSString createExpression, id ) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createExpression_1_1, createExpression !is null ? createExpression.id : 0, !is null ? .id : 0);
- // return result !is 0 ? new DOMXPathExpression(result) : null;
- // }
-
- // public DOMXPathExpression createExpression_resolver_(NSString expression, id resolver) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createExpression_1resolver_1, expression !is null ? expression.id : 0, resolver !is null ? resolver.id : 0);
- // return result !is 0 ? new DOMXPathExpression(result) : null;
- // }
-
- // public id createNSResolver(DOMNode nodeResolver) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createNSResolver_1, nodeResolver !is null ? nodeResolver.id : 0);
- // return result !is 0 ? new id (result) : null;
- // }
-
- // public DOMNodeIterator createNodeIterator____(DOMNode createNodeIterator, int , id , bool ) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createNodeIterator_1_1_1_1, createNodeIterator !is null ? createNodeIterator.id : 0, , !is null ? .id : 0, );
- // return result !is 0 ? new DOMNodeIterator(result) : null;
- // }
-
- // public DOMNodeIterator createNodeIterator_whatToShow_filter_expandEntityReferences_(DOMNode root, int whatToShow, id filter, bool expandEntityReferences) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createNodeIterator_1whatToShow_1filter_1expandEntityReferences_1, root !is null ? root.id : 0, whatToShow, filter !is null ? filter.id : 0, expandEntityReferences);
- // return result !is 0 ? new DOMNodeIterator(result) : null;
- // }
-
- // public DOMProcessingInstruction createProcessingInstruction__(NSString createProcessingInstruction, NSString ) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createProcessingInstruction_1_1, createProcessingInstruction !is null ? createProcessingInstruction.id : 0, !is null ? .id : 0);
- // return result !is 0 ? new DOMProcessingInstruction(result) : null;
- // }
+public this(objc.id id) {
+ super(id);
+}
- // public DOMProcessingInstruction createProcessingInstruction_data_(NSString target, NSString data) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createProcessingInstruction_1data_1, target !is null ? target.id : 0, data !is null ? data.id : 0);
- // return result !is 0 ? new DOMProcessingInstruction(result) : null;
- // }
-
- // public DOMRange createRange() {
- // int result = OS.objc_msgSend(this.id, OS.sel_createRange);
- // return result !is 0 ? new DOMRange(result) : null;
- // }
-
- // public DOMText createTextNode(NSString data) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createTextNode_1, data !is null ? data.id : 0);
- // return result !is 0 ? new DOMText(result) : null;
- // }
-
- // public DOMTreeWalker createTreeWalker____(DOMNode createTreeWalker, int , id , bool ) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createTreeWalker_1_1_1_1, createTreeWalker !is null ? createTreeWalker.id : 0, , !is null ? .id : 0, );
- // return result !is 0 ? new DOMTreeWalker(result) : null;
- // }
-
- // public DOMTreeWalker createTreeWalker_whatToShow_filter_expandEntityReferences_(DOMNode root, int whatToShow, id filter, bool expandEntityReferences) {
- // int result = OS.objc_msgSend(this.id, OS.sel_createTreeWalker_1whatToShow_1filter_1expandEntityReferences_1, root !is null ? root.id : 0, whatToShow, filter !is null ? filter.id : 0, expandEntityReferences);
- // return result !is 0 ? new DOMTreeWalker(result) : null;
- // }
-
- // public DOMXPathResult evaluate_____(NSString evaluate, DOMNode , id , short , DOMXPathResult ) {
- // int result = OS.objc_msgSend(this.id, OS.sel_evaluate_1_1_1_1_1, evaluate !is null ? evaluate.id : 0, !is null ? .id : 0, !is null ? .id : 0, , !is null ? .id : 0);
- // return result !is 0 ? new DOMXPathResult(result) : null;
- // }
-
- // public DOMXPathResult evaluate_contextNode_resolver_type_inResult_(NSString expression, DOMNode contextNode, id resolver, short type, DOMXPathResult inResult) {
- // int result = OS.objc_msgSend(this.id, OS.sel_evaluate_1contextNode_1resolver_1type_1inResult_1, expression !is null ? expression.id : 0, contextNode !is null ? contextNode.id : 0, resolver !is null ? resolver.id : 0, type, inResult !is null ? inResult.id : 0);
- // return result !is 0 ? new DOMXPathResult(result) : null;
- // }
-
- // public DOMCSSStyleDeclaration getComputedStyle__(DOMElement getComputedStyle, NSString ) {
- // int result = OS.objc_msgSend(this.id, OS.sel_getComputedStyle_1_1, getComputedStyle !is null ? getComputedStyle.id : 0, !is null ? .id : 0);
- // return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
- // }
-
- // public DOMCSSStyleDeclaration getComputedStyle_pseudoElement_(DOMElement element, NSString pseudoElement) {
- // int result = OS.objc_msgSend(this.id, OS.sel_getComputedStyle_1pseudoElement_1, element !is null ? element.id : 0, pseudoElement !is null ? pseudoElement.id : 0);
- // return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
- // }
-
- // public DOMElement getElementById(NSString elementId) {
- // int result = OS.objc_msgSend(this.id, OS.sel_getElementById_1, elementId !is null ? elementId.id : 0);
- // return result !is 0 ? new DOMElement(result) : null;
- // }
+public this(cocoa.id id) {
+ super(id);
+}
- // public DOMNodeList getElementsByTagName(NSString tagname) {
- // int result = OS.objc_msgSend(this.id, OS.sel_getElementsByTagName_1, tagname !is null ? tagname.id : 0);
- // return result !is 0 ? new DOMNodeList(result) : null;
- // }
-
- // public DOMNodeList getElementsByTagNameNS__(NSString getElementsByTagNameNS, NSString ) {
- // int result = OS.objc_msgSend(this.id, OS.sel_getElementsByTagNameNS_1_1, getElementsByTagNameNS !is null ? getElementsByTagNameNS.id : 0, !is null ? .id : 0);
- // return result !is 0 ? new DOMNodeList(result) : null;
- // }
-
- // public DOMNodeList getElementsByTagNameNS_localName_(NSString namespaceURI, NSString localName) {
- // int result = OS.objc_msgSend(this.id, OS.sel_getElementsByTagNameNS_1localName_1, namespaceURI !is null ? namespaceURI.id : 0, localName !is null ? localName.id : 0);
- // return result !is 0 ? new DOMNodeList(result) : null;
- // }
-
- // public DOMCSSRuleList getMatchedCSSRules_pseudoElement_(DOMElement element, NSString pseudoElement) {
- // int result = OS.objc_msgSend(this.id, OS.sel_getMatchedCSSRules_1pseudoElement_1, element !is null ? element.id : 0, pseudoElement !is null ? pseudoElement.id : 0);
- // return result !is 0 ? new DOMCSSRuleList(result) : null;
- // }
-
- // public DOMCSSRuleList getMatchedCSSRules_pseudoElement_authorOnly_(DOMElement element, NSString pseudoElement, bool authorOnly) {
- // int result = OS.objc_msgSend(this.id, OS.sel_getMatchedCSSRules_1pseudoElement_1authorOnly_1, element !is null ? element.id : 0, pseudoElement !is null ? pseudoElement.id : 0, authorOnly);
- // return result !is 0 ? new DOMCSSRuleList(result) : null;
- // }
+public WebFrame webFrame() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_webFrame);
+ return result !is null ? new WebFrame(result) : null;
+}
- // public DOMCSSStyleDeclaration getOverrideStyle__(DOMElement getOverrideStyle, NSString ) {
- // int result = OS.objc_msgSend(this.id, OS.sel_getOverrideStyle_1_1, getOverrideStyle !is null ? getOverrideStyle.id : 0, !is null ? .id : 0);
- // return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
- // }
-
- // public DOMCSSStyleDeclaration getOverrideStyle_pseudoElement_(DOMElement element, NSString pseudoElement) {
- // int result = OS.objc_msgSend(this.id, OS.sel_getOverrideStyle_1pseudoElement_1, element !is null ? element.id : 0, pseudoElement !is null ? pseudoElement.id : 0);
- // return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
- // }
-
- // public DOMNode importNode__(DOMNode importNode, bool ) {
- // int result = OS.objc_msgSend(this.id, OS.sel_importNode_1_1, importNode !is null ? importNode.id : 0, );
- // return result !is 0 ? new DOMNode(result) : null;
- // }
-
- // public DOMNode importNode_deep_(DOMNode importedNode, bool deep) {
- // int result = OS.objc_msgSend(this.id, OS.sel_importNode_1deep_1, importedNode !is null ? importedNode.id : 0, deep);
- // return result !is 0 ? new DOMNode(result) : null;
- // }
-
- public WebFrame webFrame () {
- objc.id result = OS.objc_msgSend(this.id, OS.sel_webFrame);
- return result !is null ? new WebFrame(result) : null;
- }
-
- /* DOMEventTarget */
-
- public void addEventListener_listener_useCapture (NSString type, id listener, bool useCapture) {
- OS.objc_msgSend(this.id, OS.sel_addEventListener_1listener_1useCapture_1, type !is null ? type.id : null,
- listener !is null ? listener.id : null, useCapture);
- }
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/DOMEvent.d
--- a/dwt/internal/cocoa/DOMEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/DOMEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,69 +1,40 @@
/*******************************************************************************
+ * 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
+ *
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.cocoa.DOMEvent;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.objc : id;
+import objc = dwt.internal.objc.runtime;
public class DOMEvent : NSObject {
- public this () {
- super();
- }
-
- public this (objc.id id) {
- super(id);
- }
-
- public bool bubbles () {
- return OS.objc_msgSend(this.id, OS.sel_bubbles) !is null;
- }
+public this() {
+ super();
+}
- public bool cancelable () {
- return OS.objc_msgSend(this.id, OS.sel_cancelable) !is null;
- }
-
- public id currentTarget () {
- objc.id result = OS.objc_msgSend(this.id, OS.sel_currentTarget);
- return result !is null ? new id(result) : null;
- }
-
- public short eventPhase () {
- return cast(short) OS.objc_msgSend(this.id, OS.sel_eventPhase);
- }
+public this(objc.id id) {
+ super(id);
+}
- public void initEvent___ (NSString initEvent, bool canBubbleArg, bool cancelableArg) {
- OS.objc_msgSend(this.id, OS.sel_initEvent_1_1_1, initEvent !is null ? initEvent.id : null, canBubbleArg, cancelableArg);
- }
-
- public void initEvent_canBubbleArg_cancelableArg_ (NSString eventTypeArg, bool canBubbleArg, bool cancelableArg) {
- OS.objc_msgSend(this.id, OS.sel_initEvent_1canBubbleArg_1cancelableArg_1, eventTypeArg !is null ? eventTypeArg.id : null, canBubbleArg,
- cancelableArg);
- }
-
- public void preventDefault () {
- OS.objc_msgSend(this.id, OS.sel_preventDefault);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public void stopPropagation () {
- OS.objc_msgSend(this.id, OS.sel_stopPropagation);
- }
-
- public id target () {
- objc.id result = OS.objc_msgSend(this.id, OS.sel_target);
- return result !is null ? new id(result) : null;
- }
+public void preventDefault() {
+ OS.objc_msgSend(this.id, OS.sel_preventDefault);
+}
- public long timeStamp () {
- return cast(long) OS.objc_msgSend(this.id, OS.sel_timeStamp);
- }
-
- public NSString type () {
- objc.id result = OS.objc_msgSend(this.id, OS.sel_type);
- return result !is null ? new NSString(result) : null;
- }
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/DOMKeyboardEvent.d
--- a/dwt/internal/cocoa/DOMKeyboardEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/DOMKeyboardEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,57 +1,60 @@
/*******************************************************************************
+ * 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
+ *
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.cocoa.DOMKeyboardEvent;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSString;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
+import dwt.internal.cocoa.DOMUIEvent;
import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
-public class DOMKeyboardEvent : NSObject {
-
- public this () {
- super();
- }
+public class DOMKeyboardEvent : DOMUIEvent {
- public this (int id) {
- super(id);
- }
+public this() {
+ super();
+}
- public bool altKey () {
- return OS.objc_msgSend(this.id, OS.sel_altKey) !is 0;
- }
+public this(objc.id id) {
+ super(id);
+}
- public int charCode () {
- return OS.objc_msgSend(this.id, OS.sel_charCode);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public bool ctrlKey () {
- return OS.objc_msgSend(this.id, OS.sel_ctrlKey) !is 0;
- }
+public bool altKey() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_altKey);
+}
- public bool getModifierState (NSString keyIdentifierArg) {
- return OS.objc_msgSend(this.id, OS.sel_getModifierState_1, keyIdentifierArg !is null ? keyIdentifierArg.id : 0) !is 0;
- }
+public int charCode() {
+ return cast(int)/*64*/OS.objc_msgSend(this.id, OS.sel_charCode);
+}
- public int keyCode () {
- return OS.objc_msgSend(this.id, OS.sel_keyCode);
- }
+public bool ctrlKey() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_ctrlKey);
+}
- public int keyLocation () {
- return OS.objc_msgSend(this.id, OS.sel_keyLocation);
- }
-
- public bool metaKey () {
- return OS.objc_msgSend(this.id, OS.sel_metaKey) !is 0;
- }
+public int keyCode() {
+ return cast(int)/*64*/OS.objc_msgSend(this.id, OS.sel_keyCode);
+}
- public void preventDefault () {
- OS.objc_msgSend(this.id, OS.sel_preventDefault);
- }
+public bool metaKey() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_metaKey);
+}
- public bool shiftKey () {
- return OS.objc_msgSend(this.id, OS.sel_shiftKey) !is 0;
- }
+public bool shiftKey() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_shiftKey);
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/DOMMouseEvent.d
--- a/dwt/internal/cocoa/DOMMouseEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/DOMMouseEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,73 +1,64 @@
/*******************************************************************************
+ * 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
+ *
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.cocoa.DOMMouseEvent;
import dwt.dwthelper.utils;
-import dwt.internal.cocoa.NSObject;
-
-public class DOMMouseEvent : NSObject {
-
- public this () {
- super();
- }
+import cocoa = dwt.internal.cocoa.id;
+import dwt.internal.cocoa.DOMUIEvent;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
- public this (int id) {
- super(id);
- }
+public class DOMMouseEvent : DOMUIEvent {
- public bool altKey () {
- return OS.objc_msgSend(this.id, OS.sel_altKey) !is 0;
- }
+public this() {
+ super();
+}
- public short button () {
- return cast(short) OS.objc_msgSend(this.id, OS.sel_button);
- }
-
- public int clientX () {
- return OS.objc_msgSend(this.id, OS.sel_clientX);
- }
+public this(objc.id id) {
+ super(id);
+}
- public int clientY () {
- return OS.objc_msgSend(this.id, OS.sel_clientY);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public bool ctrlKey () {
- return OS.objc_msgSend(this.id, OS.sel_ctrlKey) !is 0;
- }
+public bool altKey() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_altKey);
+}
- public int detail () {
- return OS.objc_msgSend(this.id, OS.sel_detail);
- }
-
- //public void initMouseEvent_______________(NSString initMouseEvent, bool canBubble, bool cancelable, DOMAbstractView view, int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, short button, id relatedTarget) {
- // OS.objc_msgSend(this.id, OS.sel_initMouseEvent_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1, initMouseEvent !is null ? initMouseEvent.id : 0, canBubble, cancelable, view !is null ? view.id : 0, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget !is null ? relatedTarget.id : 0);
- //}
+public short button() {
+ return cast(short)OS.objc_msgSend(this.id, OS.sel_button);
+}
- //public void initMouseEvent_canBubble_cancelable_view_detail_screenX_screenY_clientX_clientY_ctrlKey_altKey_shiftKey_metaKey_button_relatedTarget_(NSString type, bool canBubble, bool cancelable, DOMAbstractView view, int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, short button, id relatedTarget) {
- // OS.objc_msgSend(this.id, OS.sel_initMouseEvent_1canBubble_1cancelable_1view_1detail_1screenX_1screenY_1clientX_1clientY_1ctrlKey_1altKey_1shiftKey_1metaKey_1button_1relatedTarget_1, type !is null ? type.id : 0, canBubble, cancelable, view !is null ? view.id : 0, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget !is null ? relatedTarget.id : 0);
- //}
+public int clientX() {
+ return cast(int)/*64*/OS.objc_msgSend(this.id, OS.sel_clientX);
+}
- public bool metaKey () {
- return OS.objc_msgSend(this.id, OS.sel_metaKey) !is 0;
- }
+public int clientY() {
+ return cast(int)/*64*/OS.objc_msgSend(this.id, OS.sel_clientY);
+}
- public id relatedTarget () {
- int result = OS.objc_msgSend(this.id, OS.sel_relatedTarget);
- return result !is 0 ? new id(result) : null;
- }
+public bool ctrlKey() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_ctrlKey);
+}
- public int screenX () {
- return OS.objc_msgSend(this.id, OS.sel_screenX);
- }
+public bool metaKey() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_metaKey);
+}
- public int screenY () {
- return OS.objc_msgSend(this.id, OS.sel_screenY);
- }
-
- public bool shiftKey () {
- return OS.objc_msgSend(this.id, OS.sel_shiftKey) !is 0;
- }
+public bool shiftKey() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_shiftKey);
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/DOMUIEvent.d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/DOMUIEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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
+ *
+ * Port to the D programming language:
+ * Jacob Carlborg
+ *******************************************************************************/
+module dwt.internal.cocoa.DOMUIEvent;
+
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
+import dwt.internal.cocoa.DOMEvent;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class DOMUIEvent : DOMEvent {
+
+public this() {
+ super();
+}
+
+public this(objc.id id) {
+ super(id);
+}
+
+public this(cocoa.id id) {
+ super(id);
+}
+
+public int detail() {
+ return cast(int)/*64*/OS.objc_msgSend(this.id, OS.sel_detail);
+}
+
+}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/DOMWheelEvent.d
--- a/dwt/internal/cocoa/DOMWheelEvent.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/DOMWheelEvent.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,60 +1,64 @@
/*******************************************************************************
+ * 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
+ *
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.cocoa.DOMWheelEvent;
import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
public class DOMWheelEvent : NSObject {
- public this () {
- super();
- }
+public this() {
+ super();
+}
- public this (int id) {
- super(id);
- }
-
- public bool altKey () {
- return OS.objc_msgSend(this.id, OS.sel_altKey) !is 0;
- }
+public this(objc.id id) {
+ super(id);
+}
- public int clientX () {
- return OS.objc_msgSend(this.id, OS.sel_clientX);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public int clientY () {
- return OS.objc_msgSend(this.id, OS.sel_clientY);
- }
+public bool altKey() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_altKey);
+}
- public bool ctrlKey () {
- return OS.objc_msgSend(this.id, OS.sel_ctrlKey) !is 0;
- }
+public int clientX() {
+ return cast(int)/*64*/OS.objc_msgSend(this.id, OS.sel_clientX);
+}
- public bool isHorizontal () {
- return OS.objc_msgSend(this.id, OS.sel_isHorizontal) !is 0;
- }
+public int clientY() {
+ return cast(int)/*64*/OS.objc_msgSend(this.id, OS.sel_clientY);
+}
- public bool metaKey () {
- return OS.objc_msgSend(this.id, OS.sel_metaKey) !is 0;
- }
-
- public int screenX () {
- return OS.objc_msgSend(this.id, OS.sel_screenX);
- }
+public bool ctrlKey() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_ctrlKey);
+}
- public int screenY () {
- return OS.objc_msgSend(this.id, OS.sel_screenY);
- }
+public bool metaKey() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_metaKey);
+}
- public bool shiftKey () {
- return OS.objc_msgSend(this.id, OS.sel_shiftKey) !is 0;
- }
+public bool shiftKey() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_shiftKey);
+}
- public int wheelDelta () {
- return OS.objc_msgSend(this.id, OS.sel_wheelDelta);
- }
+public int wheelDelta() {
+ return cast(int)/*64*/OS.objc_msgSend(this.id, OS.sel_wheelDelta);
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/IconRef.d
--- a/dwt/internal/cocoa/IconRef.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-/**
- * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
- * Authors: Jacob Carlborg
- * Version: Initial created: Jul 27, 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.cocoa.IconRef;
-
-extern (C):
-
-alias void* OpaqueIconRef;
-alias OpaqueIconRef* IconRef;
\ No newline at end of file
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/MacGenerator.d
--- a/dwt/internal/cocoa/MacGenerator.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,839 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.MacGenerator;
-
-import tango.text.xml.Document;
-
-import dwt.dwthelper.BufferedOutputStream;
-import dwt.dwthelper.FileOutputStream;
-/*import dwt.dwthelper.PrintStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import com.sun.org.apache.xerces.internal.parsers.DOMParser;
-import org.w3c.dom.*;*/
-
-import dwt.dwthelper.utils;
-
-public class MacGenerator {
- String[] classes;
- String xml[];
- String outputDir;
-
- //PrintStream output;
-
-public this(String[] xml)
-{
- this.xml = xml;
-}
-
-public void print (String str) {
- /*PrintStream output = this.output;
- if (output is null) output = System.out;
- output.print(str);*/
-}
-
-public void println() {
- /*PrintStream output = this.output;
- if (output is null) output = System.out;
- output.println();*/
-}
-
-public void generateConstants()
-{
- foreach (str ; xml)
- {
- Document document = new Document!(char);
- document.parse(str);
-
- foreach (node ; document.root.children)
- {
- if ("constant" == node.name)
- {
- Node attribute;
-
- print("public static final native int ");
-
- foreach (a ; node.attributes)
- if (a.name == "name")
- {
- attribute = a;
- break;
- }
-
- print(attribute.value);
- print("();");
- println;
- }
- }
- }
-}
-
-public void generateConstantsMetaData()
-{
- foreach (str ; xml)
- {
- Document document = new Document!(char);
- document.parse(str);
-
- foreach (node ; document.root.children)
- {
- if ("constant" == node.name)
- {
- Node attribute;
-
- print("OS_");
-
- foreach (a ; node.attributes)
- if (a.name == "name")
- {
- attribute = a;
- break;
- }
-
- print(attribute.value);
- print("=flags=const");
- println;
- }
- }
- }
-}
-
-public void generateEnums()
-{
- foreach (str ; xml)
- {
- Document document = new Document!(char);
- document.parse(str);
-
- foreach (node ; document.root.children)
- {
- if ("enum" == node.name)
- {
- Node attributeName = null;
- Node attributeValue = null;
-
- print("OS_");
-
- foreach (a ; node.attributes)
- if (a.name == "value")
- {
- attributeValue = a;
- break;
- }
-
- if (attributeValue !is null)
- {
- print("public static final ");
-
- if (attributeValue.value.indexOf('.') !is -1)
- print("double ");
-
- else
- print("int ");
- }
-
- foreach (a ; node.attributes)
- if (a.name == "name")
- {
- attributeName = a;
- break;
- }
-
- print(attributeName.value);
- print(" = ");
- print(attributeValue.value);
- print(";");
- println;
- }
- }
- }
-}
-
-bool isStruct(Node node)
-{
- String code;
-
- foreach (a ; node.attributes)
- if(a.name == "type")
- {
- code = a.value;
- break;
- }
-
- return code.startsWith("{");
-}
-
-bool isFloatingPoint(Node node) {
- NamedNodeMap attributes = node.getAttributes();
- String code = attributes.getNamedItem("type").getNodeValue();
- return code.opEquals("f") || code.opEquals("d");
-}
-
-bool isObject(Node node) {
- NamedNodeMap attributes = node.getAttributes();
- String code = attributes.getNamedItem("type").getNodeValue();
- return code.opEquals("@");
-}
-
-bool isBoolean(Node node) {
- NamedNodeMap attributes = node.getAttributes();
- String code = attributes.getNamedItem("type").getNodeValue();
- return code.opEquals("B");
-}
-
-bool getGenerateClass(String className) {
- if (classes !is null) {
- for (int i = 0; i < classes.length; i++) {
- if (className.opEquals(classes[i])) return true;
- }
- return false;
- }
- return true;
-}
-
-public bool isUnique(Node method, NodeList methods) {
- String methodName = method.getAttributes().getNamedItem("selector").getNodeValue();
- int index = methodName.indexOf(":");
- if (index !is -1) methodName = methodName.substring(0, index);
- for (int j = 0; j < methods.getLength(); j++) {
- Node other = methods.item(j);
- NamedNodeMap attributes = other.getAttributes();
- Node otherSel = null;
- if (attributes !is null) otherSel = attributes.getNamedItem("selector");
- if (other !is method && otherSel !is null) {
- String otherName = otherSel.getNodeValue();
- index = otherName.indexOf(":");
- if (index !is -1) otherName = otherName.substring(0, index);
- if (methodName.opEquals(otherName)) {
- return false;
- }
- }
- }
- return true;
-}
-
-public void generateClasses() {
- for (int x = 0; x < xml.length; x++) {
- DOMParser parser = new DOMParser();
- parser.parse(xml[x]);
- Document document = parser.getDocument();
- NodeList list = document.getDocumentElement().getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node node = list.item(i);
- if ("class".opEquals(node.getLocalName())) {
- NamedNodeMap attributes = node.getAttributes();
- String name = attributes.getNamedItem("name").getNodeValue();
- if (getGenerateClass(name)) {
- if (outputDir !is null) {
- FileOutputStream is = new FileOutputStream(outputDir + "/" + name + ".java");
- out = new PrintStream(new BufferedOutputStream(is));
- }
- out("module dwt.internal.cocoa;");
- outln();
- outln();
- out("public class ");
- out(name);
- if (name.opEquals("NSObject")) {
- out(" : id {");
- } else {
- out(" : NSObject {");
- }
- outln();
- outln();
- out("public ");
- out(name);
- out("() {");
- outln();
- out("\tsuper();");
- outln();
- out("}");
- outln();
- outln();
- out("public ");
- out(name);
- out("(int id) {");
- outln();
- out("\tsuper(id);");
- outln();
- out("}");
- outln();
- outln();
- NodeList methods = node.getChildNodes();
- for (int j = 0; j < methods.getLength(); j++) {
- Node method = methods.item(j);
- if ("method".opEquals(method.getLocalName())) {
- String sel = method.getAttributes().getNamedItem("selector").getNodeValue();
- out("public ");
- bool isStatic = method.getAttributes().getNamedItem("class_method") !is null;
- if (isStatic) out("static ");
- Node returnNode = getReturnNode(method.getChildNodes());
- if (getType(returnNode).opEquals("void")) returnNode = null;
- if (returnNode !is null) {
- out(getJavaType(returnNode));
- out(" ");
- } else {
- out("void ");
- }
- String methodName = sel;
- if (isUnique(method, methods)) {
- int index = methodName.indexOf(":");
- if (index !is -1) methodName = methodName.substring(0, index);
- } else {
- methodName = methodName.replaceAll(":", "_");
- if (isStatic) methodName = "static_" + methodName;
- }
- out(methodName);
- out("(");
- NodeList params = method.getChildNodes();
- bool first = true;
- for (int k = 0; k < params.getLength(); k++) {
- Node param = params.item(k);
- if ("arg".opEquals(param.getLocalName())) {
- NamedNodeMap paramAttributes = param.getAttributes();
- if (!first) out(", ");
- out(getJavaType(param));
- first = false;
- out(" ");
- String paramName = paramAttributes.getNamedItem("name").getNodeValue();
- if (paramName.opEquals("bool")) paramName = "b";
- out(paramName);
- }
- }
- out(") {");
- outln();
- if (returnNode !is null && isStruct(returnNode)) {
- String type = getJavaType(returnNode);
- out("\t");
- out(type);
- out(" result = new ");
- out(type);
- out("();");
- outln();
- out("\tOS.objc_msgSend_stret(result, ");
- } else if (returnNode !is null && isFloatingPoint(returnNode)) {
- String type = getJavaType(returnNode);
- out("\treturn ");
- if (type.opEquals("float")) out("(float)");
- out("OS.objc_msgSend_fpret(");
- } else if (returnNode !is null && isObject(returnNode)) {
- out("\tint result = OS.objc_msgSend(");
- } else {
- if (returnNode !is null) {
- out("\treturn ");
- String type = getJavaType(returnNode);
- if (!(type.opEquals("int") || type.opEquals("bool"))) {
- out("(");
- out(type);
- out(")");
- }
- } else {
- out("\t");
- }
- out("OS.objc_msgSend(");
- }
- if (isStatic) {
- out("OS.class_");
- out(name);
- } else {
- out("this.id");
- }
- out(", OS.");
- out(getSelConst(sel));
- first = false;
- for (int k = 0; k < params.getLength(); k++) {
- Node param = params.item(k);
- if ("arg".opEquals(param.getLocalName())) {
- NamedNodeMap paramAttributes = param.getAttributes();
- if (!first) out(", ");
- first = false;
- String paramName = paramAttributes.getNamedItem("name").getNodeValue();
- if (paramName.opEquals("bool")) paramName = "b";
- if (isObject(param)) {
- out(paramName);
- out(" !is null ? ");
- out(paramName);
- out(".id : 0");
- } else {
- out(paramName);
- }
- }
- }
- out(")");
- if (returnNode !is null && isBoolean(returnNode)) {
- out(" !is 0");
- }
- out(";");
- outln();
- if (returnNode !is null && isObject(returnNode)) {
- if (!isStatic && getJavaType(returnNode).opEquals(name)) {
- out("\treturn result is this.id ? this : (result !is 0 ? new ");
- out(getJavaType(returnNode));
- out("(result) : null);");
- } else {
- out("\treturn result !is 0 ? new ");
- out(getJavaType(returnNode));
- out("(result) : null;");
- }
- outln();
- } else if (returnNode !is null && isStruct(returnNode)) {
- out("\treturn result;");
- outln();
- }
- out("}");
- outln();
- outln();
- }
- }
- out("}");
- outln();
- if (outputDir !is null) {
- out.close();
- out = null;
- }
- }
- }
- }
- }
-}
-
-public void generateSelectorsConst() {
- HashSet set = new HashSet();
- for (int x = 0; x < xml.length; x++) {
- DOMParser parser = new DOMParser();
- parser.parse(xml[x]);
- Document document = parser.getDocument();
- NodeList list = document.getDocumentElement().getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node node = list.item(i);
- if ("class".opEquals(node.getLocalName())) {
- NamedNodeMap attributes = node.getAttributes();
- String name = attributes.getNamedItem("name").getNodeValue();
- if (getGenerateClass(name)) {
- NodeList methods = node.getChildNodes();
- for (int j = 0; j < methods.getLength(); j++) {
- Node method = methods.item(j);
- if ("method".opEquals(method.getLocalName())) {
- String sel = method.getAttributes().getNamedItem("selector").getNodeValue();
- set.add(sel);
- }
- }
- }
- }
- }
- }
- for (Iterator iterator = set.iterator(); iterator.hasNext();) {
- String sel = (String) iterator.next();
- String selConst = getSelConst(sel);
- out("public static final int ");
- out(selConst);
- out(" = ");
- out("sel_registerName(\"");
- out(sel);
- out("\");");
- outln();
- }
-}
-
-public void generateSends() {
- HashSet set = new HashSet();
- for (int x = 0; x < xml.length; x++) {
- DOMParser parser = new DOMParser();
- parser.parse(xml[x]);
- Document document = parser.getDocument();
- NodeList list = document.getDocumentElement().getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node node = list.item(i);
- if ("class".opEquals(node.getLocalName())) {
- NamedNodeMap attributes = node.getAttributes();
- String name = attributes.getNamedItem("name").getNodeValue();
- if (getGenerateClass(name)) {
- NodeList methods = node.getChildNodes();
- for (int j = 0; j < methods.getLength(); j++) {
- Node method = methods.item(j);
- if ("method".opEquals(method.getLocalName())) {
- Node returnNode = getReturnNode(method.getChildNodes());
- StringBuffer buffer = new StringBuffer();
- buffer.append("public static final native ");
- if (returnNode !is null && isStruct(returnNode)) {
- buffer.append("void objc_msgSend_stret(");
- buffer.append(getJavaType(returnNode));
- buffer.append(" result, ");
- } else if (returnNode !is null && isFloatingPoint(returnNode)) {
- buffer.append("double objc_msgSend_fpret(");
- } else {
- buffer.append("int objc_msgSend(");
- }
- buffer.append("int id, int sel");
- NodeList params = method.getChildNodes();
- bool first = false;
- int count = 0;
- for (int k = 0; k < params.getLength(); k++) {
- Node param = params.item(k);
- if ("arg".opEquals(param.getLocalName())) {
- if (!first) buffer.append(", ");
- if (isStruct(param)) {
- buffer.append(getJavaType(param));
- } else {
- buffer.append(getType(param));
- }
- first = false;
- buffer.append(" arg");
- buffer.append(String.valueOf(count++));
- }
- }
- buffer.append(");");
- set.add(buffer.toString());
- }
- }
- }
- }
- }
- }
- for (Iterator iterator = set.iterator(); iterator.hasNext();) {
- out(iterator.next().toString());
- outln();
- }
-}
-
-public void generateSendsMetaData() {
- HashMap set = new HashMap();
- for (int x = 0; x < xml.length; x++) {
- DOMParser parser = new DOMParser();
- parser.parse(xml[x]);
- Document document = parser.getDocument();
- NodeList list = document.getDocumentElement().getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node node = list.item(i);
- if ("class".opEquals(node.getLocalName())) {
- NamedNodeMap attributes = node.getAttributes();
- String name = attributes.getNamedItem("name").getNodeValue();
- if (getGenerateClass(name)) {
- NodeList methods = node.getChildNodes();
- for (int j = 0; j < methods.getLength(); j++) {
- Node method = methods.item(j);
- if ("method".opEquals(method.getLocalName())) {
- Node returnNode = getReturnNode(method.getChildNodes());
- StringBuffer buffer = new StringBuffer();
- if (returnNode !is null && isStruct(returnNode)) {
- buffer.append("OS_objc_1msgSend_1stret__");
- buffer.append("Lorg_eclipse_swt_internal_cocoa_");
- buffer.append(getJavaType(returnNode));
- buffer.append("_2");
- } else if (returnNode !is null && isFloatingPoint(returnNode)) {
- buffer.append("OS_objc_1msgSend_1fpret__");
- } else {
- buffer.append("OS_objc_1msgSend__");
- }
- buffer.append("II");
- NodeList params = method.getChildNodes();
- for (int k = 0; k < params.getLength(); k++) {
- Node param = params.item(k);
- if ("arg".opEquals(param.getLocalName())) {
- if (isStruct(param)) {
- buffer.append("Lorg_eclipse_swt_internal_cocoa_");
- buffer.append(getJavaType(param));
- buffer.append("_2");
- } else {
- buffer.append(getJNIType(param));
- }
- }
- }
- String key = buffer.toString();
- if (set.get(key) is null) set.put(key, method);
- }
- }
- }
- }
- }
- }
- for (Iterator iterator = set.keySet().iterator(); iterator.hasNext();) {
- String key = iterator.next().toString();
- out(key);
- out("=flags=cast");
- outln();
- int count = 2;
- if (key.indexOf("stret") !is -1) {
- count = 3;
- out(key);
- out("_0=");
- outln();
- out(key);
- out("_1=cast=(id)");
- outln();
- out(key);
- out("_2=cast=(SEL)");
- outln();
- } else {
- out(key);
- out("_0=cast=(id)");
- outln();
- out(key);
- out("_1=cast=(SEL)");
- outln();
- }
- Node method = (Node)set.get(key);
- NodeList params = method.getChildNodes();
- for (int k = 0; k < params.getLength(); k++) {
- Node param = params.item(k);
- if ("arg".opEquals(param.getLocalName())) {
- out(key);
- out("_");
- out(String.valueOf(count));
- out("=");
- if (isStruct(param)) {
- out("flags=struct");
- }
- outln();
- count++;
- }
- }
- outln();
- }
-}
-
-
-String getSelConst(String sel) {
- return "sel_" + sel.replaceAll(":", "_1");
-}
-
-public void generateClassesConst() {
- HashSet set = new HashSet();
- for (int x = 0; x < xml.length; x++) {
- DOMParser parser = new DOMParser();
- parser.parse(xml[x]);
- Document document = parser.getDocument();
- NodeList list = document.getDocumentElement().getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node node = list.item(i);
- if ("class".opEquals(node.getLocalName())) {
- NamedNodeMap attributes = node.getAttributes();
- String name = attributes.getNamedItem("name").getNodeValue();
- if (getGenerateClass(name)) {
- set.add(name);
- }
- }
- }
- }
- for (Iterator iterator = set.iterator(); iterator.hasNext();) {
- String cls = (String) iterator.next();
- String clsConst = "class_" + cls;
- out("public static final int ");
- out(clsConst);
- out(" = ");
- out("objc_getClass(\"");
- out(cls);
- out("\");");
- outln();
- }
-}
-
-Node getReturnNode(NodeList list) {
- for (int j = 0; j < list.getLength(); j++) {
- Node node = list.item(j);
- if ("retval".opEquals(node.getLocalName())) {
- return node;
- }
- }
- return null;
-}
-
-String getType(Node node) {
- NamedNodeMap attributes = node.getAttributes();
- String code = attributes.getNamedItem("type").getNodeValue();
- if (code.opEquals("c")) return "byte";
- if (code.opEquals("i")) return "int";
- if (code.opEquals("s")) return "short";
- if (code.opEquals("l")) return "int";
- if (code.opEquals("q")) return "long";
- if (code.opEquals("C")) return "byte";
- if (code.opEquals("I")) return "int";
- if (code.opEquals("S")) return "short";
- if (code.opEquals("L")) return "int";
- if (code.opEquals("Q")) return "long";
- if (code.opEquals("f")) return "float";
- if (code.opEquals("d")) return "double";
- if (code.opEquals("B")) return "bool";
- if (code.opEquals("v")) return "void";
- if (code.opEquals("*")) return "int";
- if (code.opEquals("@")) return "int";
- if (code.opEquals("#")) return "int";
- if (code.opEquals(":")) return "int";
- if (code.startsWith("^")) return "int";
- if (code.startsWith("[")) return "BAD " + code;
- if (code.startsWith("{")) {
- return attributes.getNamedItem("declared_type").getNodeValue();
- }
- if (code.startsWith("(")) return "BAD " + code;
- return "BAD " + code;
-}
-String getJNIType(Node node) {
- NamedNodeMap attributes = node.getAttributes();
- String code = attributes.getNamedItem("type").getNodeValue();
- if (code.opEquals("c")) return "B";
- if (code.opEquals("i")) return "I";
- if (code.opEquals("s")) return "S";
- if (code.opEquals("l")) return "I";
- if (code.opEquals("q")) return "J";
- if (code.opEquals("C")) return "B";
- if (code.opEquals("I")) return "I";
- if (code.opEquals("S")) return "S";
- if (code.opEquals("L")) return "I";
- if (code.opEquals("Q")) return "J";
- if (code.opEquals("f")) return "F";
- if (code.opEquals("d")) return "D";
- if (code.opEquals("B")) return "Z";
- if (code.opEquals("v")) return "V";
- if (code.opEquals("*")) return "I";
- if (code.opEquals("@")) return "I";
- if (code.opEquals("#")) return "I";
- if (code.opEquals(":")) return "I";
- if (code.startsWith("^")) return "I";
- if (code.startsWith("[")) return "BAD " + code;
- if (code.startsWith("{")) {
- return "BAD " + code;
- }
- if (code.startsWith("(")) return "BAD " + code;
- return "BAD " + code;
-}
-
-String getJavaType(Node node) {
- NamedNodeMap attributes = node.getAttributes();
- String code = attributes.getNamedItem("type").getNodeValue();
- if (code.opEquals("c")) return "byte";
- if (code.opEquals("i")) return "int";
- if (code.opEquals("s")) return "short";
- if (code.opEquals("l")) return "int";
- if (code.opEquals("q")) return "long";
- if (code.opEquals("C")) return "byte";
- if (code.opEquals("I")) return "int";
- if (code.opEquals("S")) return "short";
- if (code.opEquals("L")) return "int";
- if (code.opEquals("Q")) return "long";
- if (code.opEquals("f")) return "float";
- if (code.opEquals("d")) return "double";
- if (code.opEquals("B")) return "bool";
- if (code.opEquals("v")) return "void";
- if (code.opEquals("*")) return "int";
- if (code.opEquals("@")) {
- String type = attributes.getNamedItem("declared_type").getNodeValue();
- int index = type.indexOf('*');
- if (index !is -1) type = type.substring(0, index);
- index = type.indexOf('<');
- if (index !is -1) type = type.substring(0, index);
- return type;
- }
- if (code.opEquals("#")) return "int";
- if (code.opEquals(":")) return "int";
- if (code.startsWith("^")) return "int";
- if (code.startsWith("[")) return "BAD " + code;
- if (code.startsWith("{")) {
- return attributes.getNamedItem("declared_type").getNodeValue();
- }
- if (code.startsWith("(")) return "BAD " + code;
- return "BAD " + code;
-}
-
-public void generateFunctions() {
- for (int x = 0; x < xml.length; x++) {
- DOMParser parser = new DOMParser();
- parser.parse(xml[x]);
- Document document = parser.getDocument();
- NodeList list = document.getDocumentElement().getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node node = list.item(i);
- if ("function".opEquals(node.getLocalName())) {
- NamedNodeMap attributes = node.getAttributes();
- String name = attributes.getNamedItem("name").getNodeValue();
- out("public static final native ");
- Node returnNode = getReturnNode(node.getChildNodes());
- if (returnNode !is null) {
- out(getType(returnNode));
- out(" ");
- } else {
- out("void ");
- }
- out(name);
- out("(");
- NodeList params = node.getChildNodes();
- bool first = true;
- for (int j = 0; j < params.getLength(); j++) {
- Node param = params.item(j);
- if ("arg".opEquals(param.getLocalName())) {
- NamedNodeMap paramAttributes = param.getAttributes();
- if (!first) out(", ");
- out(getType(param));
- first = false;
- out(" ");
- out(paramAttributes.getNamedItem("name").getNodeValue());
- }
- }
- out(");");
- outln();
- }
- }
- }
-}
-
-public void generateOS() {
- out("/** Classes */");
- outln();
- generateClassesConst();
- outln();
- out("/** Selectors */");
- outln();
- generateSelectorsConst();
- outln();
- out("/** Constants */");
- outln();
- generateEnums();
- outln();
- out("/** Globals */");
- outln();
- generateConstants();
- outln();
- out("/** Functions */");
- outln();
- generateFunctions();
- outln();
- out("/** Sends */");
- outln();
- generateSends();
-}
-
-public void generateMetadata() {
- generateConstantsMetaData();
- generateSendsMetaData();
-}
-
-public void setClasses(String[] classes) {
- this.classes = classes;
-}
-
-public void setOutputDir(String dir) {
- this.outputDir = dir;
-}
-
-public static void main(String[] args) {
- MacGenerator gen = new MacGenerator(args);
-// gen.setClasses(new String[]{
-// "NSURL",
-// });
- gen.setOutputDir("/Users/adclabs/Desktop/workspace/dwt/Eclipse DWT PI/cocoa/org/eclipse/swt/internal/cocoa");
-// gen.generateOS();
-// gen.generateMetadata();
- gen.generateClasses();
-}
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSATSTypesetter.d
--- a/dwt/internal/cocoa/NSATSTypesetter.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSATSTypesetter;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSRect;
-import dwt.internal.cocoa.NSTypesetter;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSATSTypesetter : NSTypesetter
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSRect lineFragmentRectForProposedRect (NSRect proposedRect, objc.id remainingRect)
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_lineFragmentRectForProposedRect_1remainingRect_1, proposedRect, remainingRect);
- return result;
- }
-
- public static id sharedTypesetter ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSATSTypesetter, OS.sel_sharedTypesetter);
- return result !is null ? new id(result) : null;
- }
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSActionCell.d
--- a/dwt/internal/cocoa/NSActionCell.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSActionCell.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,146 +1,47 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSActionCell;
-import dwt.internal.cocoa.id;
+import dwt.dwthelper.utils;
+
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSCell;
-import dwt.internal.cocoa.NSFont;
import dwt.internal.cocoa.NSImage;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.NSText;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
-public class NSActionCell : NSCell
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public objc.SEL action ()
- {
- return cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_action);
- }
-
- public NSView controlView ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_controlView);
- return result !is null ? new NSView(result) : null;
- }
-
- public double doubleValue ()
- {
- return cast(double) OS.objc_msgSend_fpret(this.id_, OS.sel_doubleValue);
- }
+public class NSActionCell : NSCell {
- public float floatValue ()
- {
- return cast(float) OS.objc_msgSend_fpret(this.id_, OS.sel_floatValue);
- }
-
- public int intValue ()
- {
- return cast(int) OS.objc_msgSend(this.id_, OS.sel_intValue);
- }
-
- public NSInteger integerValue ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_integerValue);
- }
+public this() {
+ super();
+}
- public void setAction (objc.SEL aSelector)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector);
- }
-
- public void setAlignment (objc.id mode)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAlignment_1, mode);
- }
-
- public void setBezeled (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBezeled_1, flag);
- }
+public this(objc.id id) {
+ super(id);
+}
- public void setBordered (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBordered_1, flag);
- }
-
- public void setControlView (NSView view)
- {
- OS.objc_msgSend(this.id_, OS.sel_setControlView_1, view !is null ? view.id_ : null);
- }
-
- public void setEnabled (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setEnabled_1, flag);
- }
-
- public void setFloatingPointFormat (bool autoRange, NSUInteger leftDigits, NSUInteger rightDigits)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFloatingPointFormat_1left_1right_1, autoRange, leftDigits, rightDigits);
- }
-
- public void setFont (NSFont fontObj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFont_1, fontObj !is null ? fontObj.id_ : null);
- }
-
- public void setImage (NSImage image)
- {
- OS.objc_msgSend(this.id_, OS.sel_setImage_1, image !is null ? image.id_ : null);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public void setObjectValue (id obj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setObjectValue_1, obj !is null ? obj.id_ : null);
- }
-
- public void setTag (NSInteger anInt)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTag_1, anInt);
- }
-
- public void setTarget (id anObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTarget_1, anObject !is null ? anObject.id_ : null);
- }
+public void setAlignment(NSTextAlignment mode) {
+ OS.objc_msgSend(this.id, OS.sel_setAlignment_, mode);
+}
- public NSString StringValue ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_stringValue);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSInteger tag ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_tag);
- }
-
- public id target ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_target);
- return result !is null ? new id(result) : null;
- }
+public void setImage(NSImage image) {
+ OS.objc_msgSend(this.id, OS.sel_setImage_, image !is null ? image.id : null);
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSAffineTransform.d
--- a/dwt/internal/cocoa/NSAffineTransform.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSAffineTransform.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,19 +1,20 @@
-/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSAffineTransform;
-import dwt.internal.cocoa.CGFloat;
+import dwt.internal.c.Carbon;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSAffineTransformStruct;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSPoint;
@@ -23,102 +24,90 @@
public class NSAffineTransform : NSObject
{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
+
+public this ()
+{
+ super();
+}
- public void appendTransform (NSAffineTransform transform)
- {
- OS.objc_msgSend(this.id_, OS.sel_appendTransform_1, transform !is null ? transform.id_ : null);
- }
+public this (objc.id id)
+{
+ super(id);
+}
- public NSAffineTransform initWithTransform (NSAffineTransform transform)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithTransform_1, transform !is null ? transform.id_ : null);
- return result !is null ? this : null;
- }
+public this(cocoa.id id) {
+ super(id);
+}
+
+public void concat() {
+ OS.objc_msgSend(this.id, OS.sel_concat);
+}
- public void invert ()
- {
- OS.objc_msgSend(this.id_, OS.sel_invert);
- }
+public NSAffineTransform initWithTransform (NSAffineTransform transform)
+{
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTransform_1, transform !is null ? transform.id : null);
+ return result !is null ? this : null;
+}
- public void set ()
- {
- OS.objc_msgSend(this.id_, OS.sel_set);
- }
+public void invert ()
+{
+ OS.objc_msgSend(this.id, OS.sel_invert);
+}
- public void concat ()
- {
- OS.objc_msgSend(this.id_, OS.sel_concat);
- }
- public void prependTransform (NSAffineTransform transform)
- {
- OS.objc_msgSend(this.id_, OS.sel_prependTransform_1, transform !is null ? transform.id_ : null);
- }
+public void prependTransform (NSAffineTransform transform)
+{
+ OS.objc_msgSend(this.id, OS.sel_prependTransform_1, transform !is null ? transform.id : null);
+}
- public void rotateByDegrees (CGFloat angle)
- {
- OS.objc_msgSend(this.id_, OS.sel_rotateByDegrees_1, angle);
- }
+
+public void rotateByDegrees(float /*double*/ angle) {
+ OS.objc_msgSend(this.id, OS.sel_rotateByDegrees_, angle);
+}
- public void rotateByRadians (CGFloat angle)
- {
- OS.objc_msgSend(this.id_, OS.sel_rotateByRadians_1, angle);
- }
+public void scaleXBy(float /*double*/ scaleX, float /*double*/ scaleY) {
+ OS.objc_msgSend(this.id, OS.sel_scaleXBy_yBy_, scaleX, scaleY);
+}
- public void scaleBy (CGFloat scale)
- {
- OS.objc_msgSend(this.id_, OS.sel_scaleBy_1, scale);
- }
+public void set() {
+ OS.objc_msgSend(this.id, OS.sel_set);
+}
- public void scaleXBy (CGFloat scaleX, CGFloat scaleY)
- {
- OS.objc_msgSend(this.id_, OS.sel_scaleXBy_1yBy_1, scaleX, scaleY);
- }
+public void setTransformStruct (NSAffineTransformStruct transformStruct)
+{
+ OS.objc_msgSend(this.id, OS.sel_setTransformStruct_1, transformStruct);
+}
- public void setTransformStruct (NSAffineTransformStruct transformStruct)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTransformStruct_1, transformStruct);
- }
-
- public static NSAffineTransform transform ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAffineTransform, OS.sel_transform);
- return result !is null ? new NSAffineTransform(result) : null;
- }
+public static NSAffineTransform transform ()
+{
+ objc.id result = OS.objc_msgSend(OS.class_NSAffineTransform, OS.sel_transform);
+ return result !is null ? new NSAffineTransform(result) : null;
+}
- public NSPoint transformPoint (NSPoint aPoint)
- {
- NSPoint result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_transformPoint_1, aPoint);
- return result;
- }
+public NSPoint transformPoint (NSPoint aPoint)
+{
+ NSPoint result;
+ OS.objc_msgSend_stret(result, this.id, OS.sel_transformPoint_1, aPoint);
+ return result;
+}
- public NSSize transformSize (NSSize aSize)
- {
- NSSize result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_transformSize_1, aSize);
- return result;
- }
+public NSSize transformSize (NSSize aSize)
+{
+ NSSize result;
+ OS.objc_msgSend_stret(result, this.id, OS.sel_transformSize_1, aSize);
+ return result;
+}
- public NSAffineTransformStruct transformStruct ()
- {
- NSAffineTransformStruct result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_transformStruct);
- return result;
- }
+public NSAffineTransformStruct transformStruct ()
+{
+ NSAffineTransformStruct result;
+ OS.objc_msgSend_stret(result, this.id, OS.sel_transformStruct);
+ return result;
+}
- public void translateXBy (CGFloat deltaX, CGFloat deltaY)
- {
- OS.objc_msgSend(this.id_, OS.sel_translateXBy_1yBy_1, deltaX, deltaY);
- }
+public void translateXBy (CGFloat deltaX, CGFloat deltaY)
+{
+ OS.objc_msgSend(this.id, OS.sel_translateXBy_1yBy_1, deltaX, deltaY);
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSAffineTransformStruct.d
--- a/dwt/internal/cocoa/NSAffineTransformStruct.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSAffineTransformStruct.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 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
@@ -9,11 +9,14 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
- * Jacob Carlborg
+ * Jacob Carlborg
*******************************************************************************/
module dwt.internal.cocoa.NSAffineTransformStruct;
struct NSAffineTransformStruct {
- float m11, m12, m21, m22;
- float tX, tY;
+ //float m11, m12, m21, m22;
+ //float tX, tY;
+ public float /*double*/ m11, m12, m21, m22;
+ public float /*double*/ tX, tY;
+
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSAlert.d
--- 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
*******************************************************************************/
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;
- }
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSAnimation.d
--- a/dwt/internal/cocoa/NSAnimation.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSAnimation;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSDate : NSTimeInterval;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-alias float NSAnimationProgress;
-alias NSUInteger NSAnimationCurve;
-alias NSUInteger NSAnimationBlockingMode;
-
-public class NSAnimation : NSObject
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public void addProgressMark (NSAnimationProgress progressMark)
- {
- OS.objc_msgSend(this.id_, OS.sel_addProgressMark_1, progressMark);
- }
-
- public objc.id animationBlockingMode ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_animationBlockingMode);
- }
-
- public objc.id animationCurve ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_animationCurve);
- }
-
- public void clearStartAnimation ()
- {
- OS.objc_msgSend(this.id_, OS.sel_clearStartAnimation);
- }
-
- public void clearStopAnimation ()
- {
- OS.objc_msgSend(this.id_, OS.sel_clearStopAnimation);
- }
-
- public NSAnimationProgress currentProgress ()
- {
- return cast(NSAnimationProgress) OS.objc_msgSend_fpret(this.id_, OS.sel_currentProgress);
- }
-
- public float currentValue ()
- {
- return cast(float) OS.objc_msgSend_fpret(this.id_, OS.sel_currentValue);
- }
-
- public id delegatee ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate);
- return result !is null ? new id(result) : null;
- }
-
- public double duration ()
- {
- return OS.objc_msgSend_fpret(this.id_, OS.sel_duration);
- }
-
- public float frameRate ()
- {
- return cast(float) OS.objc_msgSend_fpret(this.id_, OS.sel_frameRate);
- }
-
- public NSAnimation initWithDuration (NSTimeInterval duration, NSAnimationCurve animationCurve)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithDuration_1animationCurve_1, duration, animationCurve);
- return result !is null ? this : null;
- }
-
- public bool isAnimating ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isAnimating) !is null;
- }
-
- public NSArray progressMarks ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_progressMarks);
- return result !is null ? new NSArray(result) : null;
- }
-
- public void removeProgressMark (NSAnimationProgress progressMark)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeProgressMark_1, progressMark);
- }
-
- public NSArray runLoopModesForAnimating ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_runLoopModesForAnimating);
- return result !is null ? new NSArray(result) : null;
- }
-
- public void setAnimationBlockingMode (NSAnimationBlockingMode animationBlockingMode)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAnimationBlockingMode_1, animationBlockingMode);
- }
-
- public void setAnimationCurve (NSAnimationCurve curve)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAnimationCurve_1, curve);
- }
-
- public void setCurrentProgress (NSAnimationProgress progress)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCurrentProgress_1, progress);
- }
-
- public void setDelegate (id delegatee)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id_ : null);
- }
-
- public void setDuration (double duration)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDuration_1, duration);
- }
-
- public void setFrameRate (float framesPerSecond)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFrameRate_1, framesPerSecond);
- }
-
- public void setProgressMarks (NSArray progressMarks)
- {
- OS.objc_msgSend(this.id_, OS.sel_setProgressMarks_1, progressMarks !is null ? progressMarks.id_ : null);
- }
-
- public void startAnimation ()
- {
- OS.objc_msgSend(this.id_, OS.sel_startAnimation);
- }
-
- public void startWhenAnimation (NSAnimation animation, NSAnimationProgress startProgress)
- {
- OS.objc_msgSend(this.id_, OS.sel_startWhenAnimation_1reachesProgress_1, animation !is null ? animation.id_ : null, startProgress);
- }
-
- public void stopAnimation ()
- {
- OS.objc_msgSend(this.id_, OS.sel_stopAnimation);
- }
-
- public void stopWhenAnimation (NSAnimation animation, NSAnimationProgress stopProgress)
- {
- OS.objc_msgSend(this.id_, OS.sel_stopWhenAnimation_1reachesProgress_1, animation !is null ? animation.id_ : null, stopProgress);
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSAnimationContext.d
--- a/dwt/internal/cocoa/NSAnimationContext.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSAnimationContext;
-
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSAnimationContext : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public static void beginGrouping ()
- {
- OS.objc_msgSend(OS.class_NSAnimationContext, OS.sel_beginGrouping);
- }
-
- public static NSAnimationContext currentContext ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAnimationContext, OS.sel_currentContext);
- return result !is null ? new NSAnimationContext(result) : null;
- }
-
- public double duration ()
- {
- return cast(double) OS.objc_msgSend_fpret(this.id_, OS.sel_duration);
- }
-
- public static void endGrouping ()
- {
- OS.objc_msgSend(OS.class_NSAnimationContext, OS.sel_endGrouping);
- }
-
- public void setDuration (double duration)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDuration_1, duration);
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSAppleEventDescriptor.d
--- a/dwt/internal/cocoa/NSAppleEventDescriptor.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSAppleEventDescriptor.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,284 +1,41 @@
-/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSAppleEventDescriptor;
-import dwt.internal.c.carboncore.MacTypes : FourCharCode;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSData;
-import dwt.internal.cocoa.NSInteger;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
-alias FourCharCode AEKeyword;
-
-public class NSAppleEventDescriptor : NSObject
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public objc.id aeDesc ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_aeDesc);
- }
-
- public static NSAppleEventDescriptor appleEventWithEventClass (objc.id eventClass, objc.id eventID, NSAppleEventDescriptor targetDescriptor,
- short returnID, objc.id transactionID)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor,
- OS.sel_appleEventWithEventClass_1eventID_1targetDescriptor_1returnID_1transactionID_1, eventClass, eventID,
- targetDescriptor !is null ? targetDescriptor.id_ : null, returnID, transactionID);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public NSAppleEventDescriptor attributeDescriptorForKeyword (objc.id keyword)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributeDescriptorForKeyword_1, keyword);
- return result is this.id_ ? this : (result !is null ? new NSAppleEventDescriptor(result) : null);
- }
-
- public bool boolValue ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_boolValue) !is null;
- }
-
- public NSAppleEventDescriptor coerceToDescriptorType (objc.id descriptorType)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_coerceToDescriptorType_1, descriptorType);
- return result is this.id_ ? this : (result !is null ? new NSAppleEventDescriptor(result) : null);
- }
-
- public NSData data ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_data);
- return result !is null ? new NSData(result) : null;
- }
-
- public NSAppleEventDescriptor descriptorAtIndex (NSInteger index)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptorAtIndex_1, index);
- return result is this.id_ ? this : (result !is null ? new NSAppleEventDescriptor(result) : null);
- }
-
- public NSAppleEventDescriptor descriptorForKeyword (objc.id keyword)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptorForKeyword_1, keyword);
- return result is this.id_ ? this : (result !is null ? new NSAppleEventDescriptor(result) : null);
- }
+public class NSAppleEventDescriptor : NSObject {
- public objc.id descriptorType ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_descriptorType);
- }
-
- public static NSAppleEventDescriptor descriptorWithBoolean (bool b)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithBoolean_1, b);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public static NSAppleEventDescriptor static_descriptorWithDescriptorType_bytes_length_ (objc.id descriptorType, /*const*/void* bytes, NSUInteger byteCount)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithDescriptorType_1bytes_1length_1, descriptorType, bytes,
- byteCount);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public static NSAppleEventDescriptor static_descriptorWithDescriptorType_data_ (objc.id descriptorType, NSData data)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithDescriptorType_1data_1, descriptorType,
- data !is null ? data.id_ : null);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public static NSAppleEventDescriptor descriptorWithEnumCode (objc.id enumerator)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithEnumCode_1, enumerator);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
+public this() {
+ super();
+}
- public static NSAppleEventDescriptor descriptorWithInt32 (int signedInt)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithInt32_1, signedInt);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public static NSAppleEventDescriptor descriptorWithString (NSString str)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithString_1, str !is null ? str.id_ : null);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public static NSAppleEventDescriptor descriptorWithTypeCode (objc.id typeCode)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithTypeCode_1, typeCode);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public objc.id enumCodeValue ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_enumCodeValue);
- }
-
- public objc.id eventClass ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_eventClass);
- }
-
- public objc.id eventID ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_eventID);
- }
+public this(objc.id id) {
+ super(id);
+}
- public NSAppleEventDescriptor initListDescriptor ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initListDescriptor);
- return result !is null ? this : null;
- }
-
- public NSAppleEventDescriptor initRecordDescriptor ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initRecordDescriptor);
- return result !is null ? this : null;
- }
-
- public NSAppleEventDescriptor initWithAEDescNoCopy (objc.id aeDesc)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithAEDescNoCopy_1, aeDesc);
- return result !is null ? this : null;
- }
-
- public NSAppleEventDescriptor initWithDescriptorType_bytes_length_ (objc.id descriptorType, /*const*/void* bytes, NSUInteger byteCount)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithDescriptorType_1bytes_1length_1, descriptorType, bytes, byteCount);
- return result !is null ? this : null;
- }
-
- public NSAppleEventDescriptor initWithDescriptorType_data_ (objc.id descriptorType, NSData data)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithDescriptorType_1data_1, descriptorType, data !is null ? data.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSAppleEventDescriptor initWithEventClass (objc.id eventClass, objc.id eventID, NSAppleEventDescriptor targetDescriptor, objc.id returnID,
- objc.id transactionID)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithEventClass_1eventID_1targetDescriptor_1returnID_1transactionID_1, eventClass,
- eventID, targetDescriptor !is null ? targetDescriptor.id_ : null, returnID, transactionID);
- return result !is null ? this : null;
- }
-
- public void insertDescriptor (NSAppleEventDescriptor descriptor, NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_insertDescriptor_1atIndex_1, descriptor !is null ? descriptor.id_ : null, index);
- }
-
- public int int32Value ()
- {
- return cast(int) OS.objc_msgSend(this.id_, OS.sel_int32Value);
- }
-
- public AEKeyword keywordForDescriptorAtIndex (NSInteger index)
- {
- return cast(AEKeyword) OS.objc_msgSend(this.id_, OS.sel_keywordForDescriptorAtIndex_1, index);
- }
-
- public static NSAppleEventDescriptor listDescriptor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_listDescriptor);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public static NSAppleEventDescriptor nullDescriptor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_nullDescriptor);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public NSInteger numberOfItems ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfItems);
- }
-
- public NSAppleEventDescriptor paramDescriptorForKeyword (objc.id keyword)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_paramDescriptorForKeyword_1, keyword);
- return result is this.id_ ? this : (result !is null ? new NSAppleEventDescriptor(result) : null);
- }
-
- public static NSAppleEventDescriptor recordDescriptor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_recordDescriptor);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public void removeDescriptorAtIndex (NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeDescriptorAtIndex_1, index);
- }
-
- public void removeDescriptorWithKeyword (objc.id keyword)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeDescriptorWithKeyword_1, keyword);
- }
-
- public void removeParamDescriptorWithKeyword (objc.id keyword)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeParamDescriptorWithKeyword_1, keyword);
- }
+public NSAppleEventDescriptor initListDescriptor() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_initListDescriptor);
+ return result is this.id ? this : (result !is null ? new NSAppleEventDescriptor(result) : null);
+}
- public short returnID ()
- {
- return cast(short) OS.objc_msgSend(this.id_, OS.sel_returnID);
- }
-
- public void setAttributeDescriptor (NSAppleEventDescriptor descriptor, objc.id keyword)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAttributeDescriptor_1forKeyword_1, descriptor !is null ? descriptor.id_ : null, keyword);
- }
-
- public void setDescriptor (NSAppleEventDescriptor descriptor, objc.id keyword)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDescriptor_1forKeyword_1, descriptor !is null ? descriptor.id_ : null, keyword);
- }
-
- public void setParamDescriptor (NSAppleEventDescriptor descriptor, objc.id keyword)
- {
- OS.objc_msgSend(this.id_, OS.sel_setParamDescriptor_1forKeyword_1, descriptor !is null ? descriptor.id_ : null, keyword);
- }
-
- public NSString StringValue ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_stringValue);
- return result !is null ? new NSString(result) : null;
- }
-
- public objc.id transactionID ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_transactionID);
- }
-
- public objc.id typeCodeValue ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_typeCodeValue);
- }
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSAppleEventManager.d
--- a/dwt/internal/cocoa/NSAppleEventManager.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSAppleEventManager;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSAppleEventDescriptor;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSAppleEventManager : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSAppleEventDescriptor appleEventForSuspensionID (objc.id suspensionID)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_appleEventForSuspensionID_1, suspensionID);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public NSAppleEventDescriptor currentAppleEvent ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_currentAppleEvent);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public NSAppleEventDescriptor currentReplyAppleEvent ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_currentReplyAppleEvent);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public short dispatchRawAppleEvent (objc.id theAppleEvent, objc.id theReply, objc.id handlerRefCon)
- {
- return cast(short) OS.objc_msgSend(this.id_, OS.sel_dispatchRawAppleEvent_1withRawReply_1handlerRefCon_1, theAppleEvent, theReply,
- handlerRefCon);
- }
-
- public void removeEventHandlerForEventClass (objc.id eventClass, objc.id eventID)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeEventHandlerForEventClass_1andEventID_1, eventClass, eventID);
- }
-
- public NSAppleEventDescriptor replyAppleEventForSuspensionID (objc.id suspensionID)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_replyAppleEventForSuspensionID_1, suspensionID);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public void resumeWithSuspensionID (objc.id suspensionID)
- {
- OS.objc_msgSend(this.id_, OS.sel_resumeWithSuspensionID_1, suspensionID);
- }
-
- public void setCurrentAppleEventAndReplyEventWithSuspensionID (objc.id suspensionID)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCurrentAppleEventAndReplyEventWithSuspensionID_1, suspensionID);
- }
-
- public void setEventHandler (id handler, objc.id handleEventSelector, objc.id eventClass, objc.id eventID)
- {
- OS.objc_msgSend(this.id_, OS.sel_setEventHandler_1andSelector_1forEventClass_1andEventID_1, handler !is null ? handler.id_ : null,
- handleEventSelector, eventClass, eventID);
- }
-
- public static NSAppleEventManager sharedAppleEventManager ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAppleEventManager, OS.sel_sharedAppleEventManager);
- return result !is null ? new NSAppleEventManager(result) : null;
- }
-
- public objc.id suspendCurrentAppleEvent ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_suspendCurrentAppleEvent);
- }
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSAppleScript.d
--- a/dwt/internal/cocoa/NSAppleScript.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSAppleScript;
-
-import dwt.internal.cocoa.NSAppleEventDescriptor;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.NSURL;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSAppleScript : NSObject
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public bool compileAndReturnError (objc.id** errorInfo)
- {
- return OS.objc_msgSend(this.id_, OS.sel_compileAndReturnError_1, errorInfo) !is null;
- }
-
- public NSAppleEventDescriptor executeAndReturnError (objc.id** errorInfo)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_executeAndReturnError_1, errorInfo);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public NSAppleEventDescriptor executeAppleEvent (NSAppleEventDescriptor event, objc.id** errorInfo)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_executeAppleEvent_1error_1, event !is null ? event.id_ : null, errorInfo);
- return result !is null ? new NSAppleEventDescriptor(result) : null;
- }
-
- public NSAppleScript initWithContentsOfURL (NSURL url, objc.id** errorInfo)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfURL_1error_1, url !is null ? url.id_ : null, errorInfo);
- return result !is null ? this : null;
- }
-
- public NSAppleScript initWithSource (NSString source)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithSource_1, source !is null ? source.id_ : null);
- return result !is null ? this : null;
- }
-
- public bool isCompiled ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isCompiled) !is null;
- }
-
- public NSString source ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_source);
- return result !is null ? new NSString(result) : null;
- }
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSApplication.d
--- a/dwt/internal/cocoa/NSApplication.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSApplication.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,488 +1,135 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSApplication;
-import dwt.internal.cocoa.id;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSDate;
-import dwt.internal.cocoa.NSDictionary;
-import dwt.internal.cocoa.NSDockTile;
import dwt.internal.cocoa.NSEvent;
-import dwt.internal.cocoa.NSException;
-import dwt.internal.cocoa.NSGraphicsContext;
import dwt.internal.cocoa.NSImage;
-import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSMenu;
import dwt.internal.cocoa.NSResponder;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSWindow;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
-public class NSApplication : NSResponder
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public void abortModal ()
- {
- OS.objc_msgSend(this.id_, OS.sel_abortModal);
- }
-
- public void activateContextHelpMode (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_activateContextHelpMode_1, sender !is null ? sender.id_ : null);
- }
-
- public void activateIgnoringOtherApps (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_activateIgnoringOtherApps_1, flag);
- }
+public class NSApplication : NSResponder {
- public void addWindowsItem (NSWindow win, NSString aString, bool isFilename)
- {
- OS.objc_msgSend(this.id_, OS.sel_addWindowsItem_1title_1filename_1, win !is null ? win.id_ : null, aString !is null ? aString.id_ : null,
- isFilename);
- }
-
- public NSImage applicationIconImage ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_applicationIconImage);
- return result !is null ? new NSImage(result) : null;
- }
+public this() {
+ super();
+}
- public void arrangeInFront (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_arrangeInFront_1, sender !is null ? sender.id_ : null);
- }
-
- public objc.id beginModalSessionForWindow_ (NSWindow theWindow)
- {
- return OS.objc_msgSend(this.id_, OS.sel_beginModalSessionForWindow_1, theWindow !is null ? theWindow.id_ : null);
- }
-
- public objc.id beginModalSessionForWindow_relativeToWindow_ (NSWindow theWindow, NSWindow docWindow)
- {
- return OS.objc_msgSend(this.id_, OS.sel_beginModalSessionForWindow_1relativeToWindow_1, theWindow !is null ? theWindow.id_ : null,
- docWindow !is null ? docWindow.id_ : null);
- }
+public this(objc.id id) {
+ super(id);
+}
- public void beginSheet (NSWindow sheet, NSWindow docWindow, id modalDelegate, objc.id didEndSelector, objc.id contextInfo)
- {
- OS.objc_msgSend(this.id_, OS.sel_beginSheet_1modalForWindow_1modalDelegate_1didEndSelector_1contextInfo_1, sheet !is null ? sheet.id_ : null,
- docWindow !is null ? docWindow.id_ : null, modalDelegate !is null ? modalDelegate.id_ : null, didEndSelector, contextInfo);
- }
-
- public void cancelUserAttentionRequest (objc.id request)
- {
- OS.objc_msgSend(this.id_, OS.sel_cancelUserAttentionRequest_1, request);
- }
-
- public void changeWindowsItem (NSWindow win, NSString aString, bool isFilename)
- {
- OS.objc_msgSend(this.id_, OS.sel_changeWindowsItem_1title_1filename_1, win !is null ? win.id_ : null, aString !is null ? aString.id_ : null,
- isFilename);
- }
-
- public NSGraphicsContext context ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_context);
- return result !is null ? new NSGraphicsContext(result) : null;
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public NSEvent currentEvent ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_currentEvent);
- return result !is null ? new NSEvent(result) : null;
- }
-
- public void deactivate ()
- {
- OS.objc_msgSend(this.id_, OS.sel_deactivate);
- }
-
- public id delegatee ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate);
- return result !is null ? new id(result) : null;
- }
+public void activateIgnoringOtherApps(bool flag) {
+ OS.objc_msgSend(this.id, OS.sel_activateIgnoringOtherApps_, flag);
+}
- public static void detachDrawingThread (objc.id selector, id target, id argument)
- {
- OS.objc_msgSend(OS.class_NSApplication, OS.sel_detachDrawingThread_1toTarget_1withObject_1, selector, target !is null ? target.id_ : null,
- argument !is null ? argument.id_ : null);
- }
-
- public void discardEventsMatchingMask (NSUInteger mask, NSEvent lastEvent)
- {
- OS.objc_msgSend(this.id_, OS.sel_discardEventsMatchingMask_1beforeEvent_1, mask, lastEvent !is null ? lastEvent.id_ : null);
- }
-
- public NSDockTile dockTile ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_dockTile);
- return result !is null ? new NSDockTile(result) : null;
- }
+public NSEvent currentEvent() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_currentEvent);
+ return result !is null ? new NSEvent(result) : null;
+}
- public void endModalSession (objc.id session)
- {
- OS.objc_msgSend(this.id_, OS.sel_endModalSession_1, session);
- }
-
- public void endSheet_ (NSWindow sheet)
- {
- OS.objc_msgSend(this.id_, OS.sel_endSheet_1, sheet !is null ? sheet.id_ : null);
- }
-
- public void endSheet_returnCode_ (NSWindow sheet, NSInteger returnCode)
- {
- OS.objc_msgSend(this.id_, OS.sel_endSheet_1returnCode_1, sheet !is null ? sheet.id_ : null, returnCode);
- }
-
- public void finishLaunching ()
- {
- OS.objc_msgSend(this.id_, OS.sel_finishLaunching);
- }
-
- public void hide (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_hide_1, sender !is null ? sender.id_ : null);
- }
+public void finishLaunching() {
+ OS.objc_msgSend(this.id, OS.sel_finishLaunching);
+}
- public void hideOtherApplications (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_hideOtherApplications_1, sender !is null ? sender.id_ : null);
- }
-
- public bool isActive ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isActive) !is null;
- }
+public void hide(cocoa.id sender) {
+ OS.objc_msgSend(this.id, OS.sel_hide_, sender !is null ? sender.id : null);
+}
- public bool isHidden ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isHidden) !is null;
- }
-
- public bool isRunning ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isRunning) !is null;
- }
-
- public NSWindow keyWindow ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_keyWindow);
- return result !is null ? new NSWindow(result) : null;
- }
+public void hideOtherApplications(cocoa.id sender) {
+ OS.objc_msgSend(this.id, OS.sel_hideOtherApplications_, sender !is null ? sender.id : null);
+}
- public NSMenu mainMenu ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_mainMenu);
- return result !is null ? new NSMenu(result) : null;
- }
-
- public NSWindow mainWindow ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_mainWindow);
- return result !is null ? new NSWindow(result) : null;
- }
-
- public NSWindow makeWindowsPerform (objc.id aSelector, bool flag)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_makeWindowsPerform_1inOrder_1, aSelector, flag);
- return result !is null ? new NSWindow(result) : null;
- }
-
- public void miniaturizeAll (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_miniaturizeAll_1, sender !is null ? sender.id_ : null);
- }
-
- public NSWindow modalWindow ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_modalWindow);
- return result !is null ? new NSWindow(result) : null;
- }
+public bool isRunning() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_isRunning);
+}
- public NSEvent nextEventMatchingMask (NSUInteger mask, NSDate expiration, NSString mode, bool deqFlag)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_nextEventMatchingMask_1untilDate_1inMode_1dequeue_1, mask,
- expiration !is null ? expiration.id_ : null, mode !is null ? mode.id_ : null, deqFlag);
- return result !is null ? new NSEvent(result) : null;
- }
-
- public void orderFrontCharacterPalette (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_orderFrontCharacterPalette_1, sender !is null ? sender.id_ : null);
- }
+public NSWindow keyWindow() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_keyWindow);
+ return result !is null ? new NSWindow(result) : null;
+}
- public void orderFrontColorPanel (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_orderFrontColorPanel_1, sender !is null ? sender.id_ : null);
- }
-
- public void orderFrontStandardAboutPanel (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_orderFrontStandardAboutPanel_1, sender !is null ? sender.id_ : null);
- }
-
- public void orderFrontStandardAboutPanelWithOptions (NSDictionary optionsDictionary)
- {
- OS.objc_msgSend(this.id_, OS.sel_orderFrontStandardAboutPanelWithOptions_1, optionsDictionary !is null ? optionsDictionary.id_ : null);
- }
-
- public NSArray orderedDocuments ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_orderedDocuments);
- return result !is null ? new NSArray(result) : null;
- }
+public NSMenu mainMenu() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_mainMenu);
+ return result !is null ? new NSMenu(result) : null;
+}
- public NSArray orderedWindows ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_orderedWindows);
- return result !is null ? new NSArray(result) : null;
- }
-
- public void postEvent (NSEvent event, bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_postEvent_1atStart_1, event !is null ? event.id_ : null, flag);
- }
-
- public void preventWindowOrdering ()
- {
- OS.objc_msgSend(this.id_, OS.sel_preventWindowOrdering);
- }
-
- public void registerServicesMenuSendTypes (NSArray sendTypes, NSArray returnTypes)
- {
- OS.objc_msgSend(this.id_, OS.sel_registerServicesMenuSendTypes_1returnTypes_1, sendTypes !is null ? sendTypes.id_ : null,
- returnTypes !is null ? returnTypes.id_ : null);
- }
+public NSEvent nextEventMatchingMask(NSUInteger mask, NSDate expiration, NSString mode, bool deqFlag) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_nextEventMatchingMask_untilDate_inMode_dequeue_, mask, expiration !is null ? expiration.id : null, mode !is null ? mode.id : null, deqFlag);
+ return result !is null ? new NSEvent(result) : null;
+}
- public void removeWindowsItem (NSWindow win)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeWindowsItem_1, win !is null ? win.id_ : null);
- }
-
- public void replyToApplicationShouldTerminate (bool shouldTerminate)
- {
- OS.objc_msgSend(this.id_, OS.sel_replyToApplicationShouldTerminate_1, shouldTerminate);
- }
-
- public void replyToOpenOrPrint (objc.id reply)
- {
- OS.objc_msgSend(this.id_, OS.sel_replyToOpenOrPrint_1, reply);
- }
-
- public void reportException (NSException theException)
- {
- OS.objc_msgSend(this.id_, OS.sel_reportException_1, theException !is null ? theException.id_ : null);
- }
-
- public NSInteger requestUserAttention (objc.id requestType)
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_requestUserAttention_1, requestType);
- }
-
- public void run ()
- {
- OS.objc_msgSend(this.id_, OS.sel_run);
- }
+public void orderFrontStandardAboutPanel(cocoa.id sender) {
+ OS.objc_msgSend(this.id, OS.sel_orderFrontStandardAboutPanel_, sender !is null ? sender.id : null);
+}
- public objc.id runModalForWindow_ (NSWindow theWindow)
- {
- return OS.objc_msgSend(this.id_, OS.sel_runModalForWindow_1, theWindow !is null ? theWindow.id_ : null);
- }
-
- public objc.id runModalForWindow_relativeToWindow_ (NSWindow theWindow, NSWindow docWindow)
- {
- return OS.objc_msgSend(this.id_, OS.sel_runModalForWindow_1relativeToWindow_1, theWindow !is null ? theWindow.id_ : null,
- docWindow !is null ? docWindow.id_ : null);
- }
-
- public objc.id runModalSession (objc.id session)
- {
- return OS.objc_msgSend(this.id_, OS.sel_runModalSession_1, session);
- }
-
- public void runPageLayout (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_runPageLayout_1, sender !is null ? sender.id_ : null);
- }
-
- public bool sendAction (objc.id theAction, id theTarget, id sender)
- {
- return OS.objc_msgSend(this.id_, OS.sel_sendAction_1to_1from_1, theAction, theTarget !is null ? theTarget.id_ : null,
- sender !is null ? sender.id_ : null) !is null;
- }
+public NSArray orderedWindows() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_orderedWindows);
+ return result !is null ? new NSArray(result) : null;
+}
- public void sendEvent (NSEvent theEvent)
- {
- OS.objc_msgSend(this.id_, OS.sel_sendEvent_1, theEvent !is null ? theEvent.id_ : null);
- }
-
- public NSMenu servicesMenu ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_servicesMenu);
- return result !is null ? new NSMenu(result) : null;
- }
+public void run() {
+ OS.objc_msgSend(this.id, OS.sel_run);
+}
- public id servicesProvider ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_servicesProvider);
- return result !is null ? new id(result) : null;
- }
+public NSInteger runModalForWindow(NSWindow theWindow) {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_runModalForWindow_, theWindow !is null ? theWindow.id : null);
+}
- public void setApplicationIconImage (NSImage image)
- {
- OS.objc_msgSend(this.id_, OS.sel_setApplicationIconImage_1, image !is null ? image.id_ : null);
- }
-
- public void setDelegate (id anObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, anObject !is null ? anObject.id_ : null);
- }
-
- public void setMainMenu (NSMenu aMenu)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMainMenu_1, aMenu !is null ? aMenu.id_ : null);
- }
+public void sendEvent(NSEvent theEvent) {
+ OS.objc_msgSend(this.id, OS.sel_sendEvent_, theEvent !is null ? theEvent.id : null);
+}
- public void setServicesMenu (NSMenu aMenu)
- {
- OS.objc_msgSend(this.id_, OS.sel_setServicesMenu_1, aMenu !is null ? aMenu.id_ : null);
- }
-
- public void setServicesProvider (id provider)
- {
- OS.objc_msgSend(this.id_, OS.sel_setServicesProvider_1, provider !is null ? provider.id_ : null);
- }
-
- public void setWindowsMenu (NSMenu aMenu)
- {
- OS.objc_msgSend(this.id_, OS.sel_setWindowsMenu_1, aMenu !is null ? aMenu.id_ : null);
- }
-
- public void setWindowsNeedUpdate (bool needUpdate)
- {
- OS.objc_msgSend(this.id_, OS.sel_setWindowsNeedUpdate_1, needUpdate);
- }
-
- public static NSApplication sharedApplication ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSApplication, OS.sel_sharedApplication);
- return result !is null ? new NSApplication(result) : null;
- }
+public void setApplicationIconImage(NSImage image) {
+ OS.objc_msgSend(this.id, OS.sel_setApplicationIconImage_, image !is null ? image.id : null);
+}
- public void showHelp (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_showHelp_1, sender !is null ? sender.id_ : null);
- }
-
- public void stop (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_stop_1, sender !is null ? sender.id_ : null);
- }
-
- public void stopModal ()
- {
- OS.objc_msgSend(this.id_, OS.sel_stopModal);
- }
+public void setDelegate(cocoa.id anObject) {
+ OS.objc_msgSend(this.id, OS.sel_setDelegate_, anObject !is null ? anObject.id : null);
+}
- public void stopModalWithCode (NSInteger returnCode)
- {
- OS.objc_msgSend(this.id_, OS.sel_stopModalWithCode_1, returnCode);
- }
-
- public id targetForAction_ (objc.SEL theAction)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_targetForAction_1, theAction);
- return result !is null ? new id(result) : null;
- }
-
- public id targetForAction_to_from_ (objc.SEL theAction, id theTarget, id sender)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_targetForAction_1to_1from_1, theAction, theTarget !is null ? theTarget.id_ : null,
- sender !is null ? sender.id_ : null);
- return result !is null ? new id(result) : null;
- }
+public static NSApplication sharedApplication() {
+ objc.id result = OS.objc_msgSend(OS.class_NSApplication, OS.sel_sharedApplication);
+ return result !is null ? new NSApplication(result) : null;
+}
- public void terminate (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_terminate_1, sender !is null ? sender.id_ : null);
- }
-
- public bool tryToPerform (objc.SEL anAction, id anObject)
- {
- return OS.objc_msgSend(this.id_, OS.sel_tryToPerform_1with_1, anAction, anObject !is null ? anObject.id_ : null) !is null;
- }
-
- public void unhide (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_unhide_1, sender !is null ? sender.id_ : null);
- }
+public void stop(cocoa.id sender) {
+ OS.objc_msgSend(this.id, OS.sel_stop_, sender !is null ? sender.id : null);
+}
- public void unhideAllApplications (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_unhideAllApplications_1, sender !is null ? sender.id_ : null);
- }
-
- public void unhideWithoutActivation ()
- {
- OS.objc_msgSend(this.id_, OS.sel_unhideWithoutActivation);
- }
-
- public void updateWindows ()
- {
- OS.objc_msgSend(this.id_, OS.sel_updateWindows);
- }
+public void terminate(cocoa.id sender) {
+ OS.objc_msgSend(this.id, OS.sel_terminate_, sender !is null ? sender.id : null);
+}
- public void updateWindowsItem (NSWindow win)
- {
- OS.objc_msgSend(this.id_, OS.sel_updateWindowsItem_1, win !is null ? win.id_ : null);
- }
-
- public id validRequestorForSendType (NSString sendType, NSString returnType)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_validRequestorForSendType_1returnType_1, sendType !is null ? sendType.id_ : null,
- returnType !is null ? returnType.id_ : null);
- return result !is null ? new id(result) : null;
- }
+public void unhideAllApplications(cocoa.id sender) {
+ OS.objc_msgSend(this.id, OS.sel_unhideAllApplications_, sender !is null ? sender.id : null);
+}
- public NSWindow windowWithWindowNumber (NSInteger windowNum)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_windowWithWindowNumber_1, windowNum);
- return result !is null ? new NSWindow(result) : null;
- }
-
- public NSArray windows ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_windows);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSMenu windowsMenu ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_windowsMenu);
- return result !is null ? new NSMenu(result) : null;
- }
+public NSArray windows() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_windows);
+ return result !is null ? new NSArray(result) : null;
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSArchiver.d
--- a/dwt/internal/cocoa/NSArchiver.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSArchiver;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSData;
-import dwt.internal.cocoa.NSMutableData;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSArchiver : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public static bool archiveRootObject (id rootObject, NSString path)
- {
- return OS.objc_msgSend(OS.class_NSArchiver, OS.sel_archiveRootObject_1toFile_1, rootObject !is null ? rootObject.id_ : null,
- path !is null ? path.id_ : null) !is null;
- }
-
- public static NSData archivedDataWithRootObject (id rootObject)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSArchiver, OS.sel_archivedDataWithRootObject_1, rootObject !is null ? rootObject.id_ : null);
- return result !is null ? new NSData(result) : null;
- }
-
- public NSMutableData archiverData ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_archiverData);
- return result !is null ? new NSMutableData(result) : null;
- }
-
- public NSString classNameEncodedForTrueClassName (NSString trueName)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_classNameEncodedForTrueClassName_1, trueName !is null ? trueName.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public void encodeClassName (NSString trueName, NSString inArchiveName)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeClassName_1intoClassName_1, trueName !is null ? trueName.id_ : null,
- inArchiveName !is null ? inArchiveName.id_ : null);
- }
-
- public void encodeConditionalObject (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeConditionalObject_1, object !is null ? object.id_ : null);
- }
-
- public void encodeRootObject (id rootObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeRootObject_1, rootObject !is null ? rootObject.id_ : null);
- }
-
- public NSArchiver initForWritingWithMutableData (NSMutableData mdata)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initForWritingWithMutableData_1, mdata !is null ? mdata.id_ : null);
- return result !is null ? this : null;
- }
-
- public void replaceObject (id object, id newObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_replaceObject_1withObject_1, object !is null ? object.id_ : null, newObject !is null ? newObject.id_ : null);
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSArray.d
--- a/dwt/internal/cocoa/NSArray.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSArray.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,342 +1,60 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSData;
-import dwt.internal.cocoa.NSEnumerator;
-import dwt.internal.cocoa.NSIndexSet;
-import dwt.internal.cocoa.NSInteger;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSPredicate;
-import dwt.internal.cocoa.NSRange;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.NSURL;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
-public class NSArray : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public void addObserver_forKeyPath_options_context_ (NSObject observer, NSString keyPath, objc.id options, objc.id context)
- {
- OS.objc_msgSend(this.id_, OS.sel_addObserver_1forKeyPath_1options_1context_1, observer !is null ? observer.id_ : null,
- keyPath !is null ? keyPath.id_ : null, options, context);
- }
-
- public void addObserver_toObjectsAtIndexes_forKeyPath_options_context_ (NSObject observer, NSIndexSet indexes, NSString keyPath, objc.id options,
- objc.id context)
- {
- OS.objc_msgSend(this.id_, OS.sel_addObserver_1toObjectsAtIndexes_1forKeyPath_1options_1context_1, observer !is null ? observer.id_ : null,
- indexes !is null ? indexes.id_ : null, keyPath !is null ? keyPath.id_ : null, options, context);
- }
-
- public static id array ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_array);
- return result !is null ? new id(result) : null;
- }
+public class NSArray : NSObject {
- public NSArray arrayByAddingObject (id anObject)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_arrayByAddingObject_1, anObject !is null ? anObject.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSArray(result) : null);
- }
-
- public NSArray arrayByAddingObjectsFromArray (NSArray otherArray)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_arrayByAddingObjectsFromArray_1, otherArray !is null ? otherArray.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSArray(result) : null);
- }
-
- public static id arrayWithArray (NSArray array)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithArray_1, array !is null ? array.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id arrayWithContentsOfFile (NSString path)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithContentsOfFile_1, path !is null ? path.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id arrayWithContentsOfURL (NSURL url)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithContentsOfURL_1, url !is null ? url.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id arrayWithObject (id anObject)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObject_1, anObject !is null ? anObject.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id static_arrayWithObjects_ (id arrayWithObjects)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObjects_1, arrayWithObjects !is null ? arrayWithObjects.id_ : null);
- return result !is null ? new id(result) : null;
- }
+public this() {
+ super();
+}
- public static id static_arrayWithObjects_count_ (/*const*/objc.id* objects, NSUInteger cnt)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObjects_1count_1, objects, cnt);
- return result !is null ? new id(result) : null;
- }
-
- public NSString componentsJoinedByString (NSString separator)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_componentsJoinedByString_1, separator !is null ? separator.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public bool containsObject (id anObject)
- {
- return OS.objc_msgSend(this.id_, OS.sel_containsObject_1, anObject !is null ? anObject.id_ : null) !is null;
- }
-
- public NSUInteger count ()
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_count);
- }
-
- public NSString description ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_description);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString descriptionWithLocale_ (id locale)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString descriptionWithLocale_indent_ (id locale, objc.id level)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithLocale_1indent_1, locale !is null ? locale.id_ : null, level);
- return result !is null ? new NSString(result) : null;
- }
+public this(objc.id id) {
+ super(id);
+}
- public NSArray filteredArrayUsingPredicate (NSPredicate predicate)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_filteredArrayUsingPredicate_1, predicate !is null ? predicate.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSArray(result) : null);
- }
-
- public id firstObjectCommonWithArray (NSArray otherArray)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_firstObjectCommonWithArray_1, otherArray !is null ? otherArray.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public void getObjects_ (objc.id objects)
- {
- OS.objc_msgSend(this.id_, OS.sel_getObjects_1, objects);
- }
-
- public void getObjects_range_ (objc.id objects, NSRange range)
- {
- OS.objc_msgSend(this.id_, OS.sel_getObjects_1range_1, objects, range);
- }
-
- public NSUInteger indexOfObject_ (id anObject)
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfObject_1, anObject !is null ? anObject.id_ : null);
- }
-
- public NSUInteger indexOfObject_inRange_ (id anObject, NSRange range)
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfObject_1inRange_1, anObject !is null ? anObject.id_ : null, range);
- }
-
- public NSUInteger indexOfObjectIdenticalTo_ (id anObject)
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfObjectIdenticalTo_1, anObject !is null ? anObject.id_ : null);
- }
-
- public NSUInteger indexOfObjectIdenticalTo_inRange_ (id anObject, NSRange range)
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfObjectIdenticalTo_1inRange_1, anObject !is null ? anObject.id_ : null, range);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public NSArray initWithArray_ (NSArray array)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithArray_1, array !is null ? array.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSArray initWithArray_copyItems_ (NSArray array, bool flag)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithArray_1copyItems_1, array !is null ? array.id_ : null, flag);
- return result !is null ? this : null;
- }
-
- public NSArray initWithContentsOfFile (NSString path)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfFile_1, path !is null ? path.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSArray initWithContentsOfURL (NSURL url)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfURL_1, url !is null ? url.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSArray initWithObjects_ (id initWithObjects)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithObjects_1, initWithObjects !is null ? initWithObjects.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSArray initWithObjects_count_ (/*const*/objc.id* objects, NSUInteger cnt)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithObjects_1count_1, objects, cnt);
- return result !is null ? this : null;
- }
+public static NSArray array() {
+ objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_array);
+ return result !is null ? new NSArray(result) : null;
+}
- public bool isEqualToArray (NSArray otherArray)
- {
- return OS.objc_msgSend(this.id_, OS.sel_isEqualToArray_1, otherArray !is null ? otherArray.id_ : null) !is null;
- }
-
- public id lastObject ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_lastObject);
- return result !is null ? new id(result) : null;
- }
-
- public void makeObjectsPerformSelector_ (objc.SEL aSelector)
- {
- OS.objc_msgSend(this.id_, OS.sel_makeObjectsPerformSelector_1, aSelector);
- }
-
- public void makeObjectsPerformSelector_withObject_ (objc.SEL aSelector, id argument)
- {
- OS.objc_msgSend(this.id_, OS.sel_makeObjectsPerformSelector_1withObject_1, aSelector, argument !is null ? argument.id_ : null);
- }
-
- public objc.id objectAtIndex (NSUInteger index)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectAtIndex_1, index);
- return result;
- // return result !is null ? new id(result) : null;
- }
-
- public NSEnumerator objectEnumerator ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectEnumerator);
- return result !is null ? new NSEnumerator(result) : null;
- }
-
- public NSArray objectsAtIndexes (NSIndexSet indexes)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectsAtIndexes_1, indexes !is null ? indexes.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSArray(result) : null);
- }
+public static NSArray arrayWithObject(cocoa.id anObject) {
+ objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObject_, anObject !is null ? anObject.id : null);
+ return result !is null ? new NSArray(result) : null;
+}
- public NSArray pathsMatchingExtensions (NSArray filterTypes)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_pathsMatchingExtensions_1, filterTypes !is null ? filterTypes.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSArray(result) : null);
- }
-
- public void removeObserver_forKeyPath_ (NSObject observer, NSString keyPath)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeObserver_1forKeyPath_1, observer !is null ? observer.id_ : null, keyPath !is null ? keyPath.id_ : null);
- }
-
- public void removeObserver_fromObjectsAtIndexes_forKeyPath_ (NSObject observer, NSIndexSet indexes, NSString keyPath)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeObserver_1fromObjectsAtIndexes_1forKeyPath_1, observer !is null ? observer.id_ : null,
- indexes !is null ? indexes.id_ : null, keyPath !is null ? keyPath.id_ : null);
- }
-
- public NSEnumerator reverseObjectEnumerator ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_reverseObjectEnumerator);
- return result !is null ? new NSEnumerator(result) : null;
- }
-
- public void setValue (id value, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_setValue_1forKey_1, value !is null ? value.id_ : null, key !is null ? key.id_ : null);
- }
-
- public NSData sortedArrayHint ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_sortedArrayHint);
- return result !is null ? new NSData(result) : null;
- }
-
- public NSArray sortedArrayUsingDescriptors (NSArray sortDescriptors)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_sortedArrayUsingDescriptors_1, sortDescriptors !is null ? sortDescriptors.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSArray(result) : null);
- }
+public bool containsObject(cocoa.id anObject) {
+ return OS.objc_msgSend_bool(this.id, OS.sel_containsObject_, anObject !is null ? anObject.id : null);
+}
- public NSArray sortedArrayUsingFunction_context_ (objc.id comparator, objc.id context)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_sortedArrayUsingFunction_1context_1, comparator, context);
- return result is this.id_ ? this : (result !is null ? new NSArray(result) : null);
- }
-
- public NSArray sortedArrayUsingFunction_context_hint_ (objc.id comparator, objc.id context, NSData hint)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_sortedArrayUsingFunction_1context_1hint_1, comparator, context,
- hint !is null ? hint.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSArray(result) : null);
- }
-
- public NSArray sortedArrayUsingSelector (objc.id comparator)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_sortedArrayUsingSelector_1, comparator);
- return result is this.id_ ? this : (result !is null ? new NSArray(result) : null);
- }
+public NSUInteger count() {
+ return OS.objc_msgSend(this.id, OS.sel_count);
+}
- public NSArray subarrayWithRange (NSRange range)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_subarrayWithRange_1, range);
- return result is this.id_ ? this : (result !is null ? new NSArray(result) : null);
- }
-
- public id valueForKey (NSString key)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_valueForKey_1, key !is null ? key.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public bool writeToFile (NSString path, bool useAuxiliaryFile)
- {
- return OS.objc_msgSend(this.id_, OS.sel_writeToFile_1atomically_1, path !is null ? path.id_ : null, useAuxiliaryFile) !is null;
- }
-
- public bool writeToURL (NSURL url, bool atomically)
- {
- return OS.objc_msgSend(this.id_, OS.sel_writeToURL_1atomically_1, url !is null ? url.id_ : null, atomically) !is null;
- }
+public cocoa.id objectAtIndex(NSUInteger index) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_objectAtIndex_, index);
+ return result !is null ? new cocoa.id(result) : null;
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSArrayController.d
--- a/dwt/internal/cocoa/NSArrayController.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,306 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSArrayController;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSIndexSet;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSObjectController;
-import dwt.internal.cocoa.NSPredicate;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSArrayController : NSObjectController
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public void add (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_add_1, sender !is null ? sender.id_ : null);
- }
-
- public void addObject (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_addObject_1,
- object !is null ? object.id_ : null);
- }
-
- public void addObjects (NSArray objects)
- {
- OS.objc_msgSend(this.id_, OS.sel_addObjects_1,
- objects !is null ? objects.id_ : null);
- }
-
- public bool addSelectedObjects (NSArray objects)
- {
- return OS.objc_msgSend(this.id_, OS.sel_addSelectedObjects_1,
- objects !is null ? objects.id_ : null) !is null;
- }
-
- public bool addSelectionIndexes (NSIndexSet indexes)
- {
- return OS.objc_msgSend(this.id_, OS.sel_addSelectionIndexes_1,
- indexes !is null ? indexes.id_ : null) !is null;
- }
-
- public bool alwaysUsesMultipleValuesMarker ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_alwaysUsesMultipleValuesMarker) !is null;
- }
-
- public NSArray arrangeObjects (NSArray objects)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_arrangeObjects_1,
- objects !is null ? objects.id_ : null);
- return result !is null ? new NSArray(result) : null;
- }
-
- public id arrangedObjects ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_arrangedObjects);
- return result !is null ? new id(result) : null;
- }
-
- public NSArray automaticRearrangementKeyPaths ()
- {
- objc.id result = OS.objc_msgSend(this.id_,
- OS.sel_automaticRearrangementKeyPaths);
- return result !is null ? new NSArray(result) : null;
- }
-
- public bool automaticallyRearrangesObjects ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_automaticallyRearrangesObjects) !is null;
- }
-
- public bool avoidsEmptySelection ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_avoidsEmptySelection) !is null;
- }
-
- public bool canInsert ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_canInsert) !is null;
- }
-
- public bool canSelectNext ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_canSelectNext) !is null;
- }
-
- public bool canSelectPrevious ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_canSelectPrevious) !is null;
- }
-
- public bool clearsFilterPredicateOnInsertion ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_clearsFilterPredicateOnInsertion) !is null;
- }
-
- public void didChangeArrangementCriteria ()
- {
- OS.objc_msgSend(this.id_, OS.sel_didChangeArrangementCriteria);
- }
-
- public NSPredicate filterPredicate ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_filterPredicate);
- return result !is null ? new NSPredicate(result) : null;
- }
-
- public void insert (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_insert_1,
- sender !is null ? sender.id_ : null);
- }
-
- public void insertObject (id object, NSUInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_insertObject_1atArrangedObjectIndex_1,
- object !is null ? object.id_ : null, index);
- }
-
- public void insertObjects (NSArray objects, NSIndexSet indexes)
- {
- OS.objc_msgSend(this.id_,
- OS.sel_insertObjects_1atArrangedObjectIndexes_1,
- objects !is null ? objects.id_ : null,
- indexes !is null ? indexes.id_ : null);
- }
-
- public bool preservesSelection ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_preservesSelection) !is null;
- }
-
- public void rearrangeObjects ()
- {
- OS.objc_msgSend(this.id_, OS.sel_rearrangeObjects);
- }
-
- public void remove (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_remove_1,
- sender !is null ? sender.id_ : null);
- }
-
- public void removeObject (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeObject_1,
- object !is null ? object.id_ : null);
- }
-
- public void removeObjectAtArrangedObjectIndex (NSUInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeObjectAtArrangedObjectIndex_1,
- index);
- }
-
- public void removeObjects (NSArray objects)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeObjects_1,
- objects !is null ? objects.id_ : null);
- }
-
- public void removeObjectsAtArrangedObjectIndexes (NSIndexSet indexes)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeObjectsAtArrangedObjectIndexes_1,
- indexes !is null ? indexes.id_ : null);
- }
-
- public bool removeSelectedObjects (NSArray objects)
- {
- return OS.objc_msgSend(this.id_, OS.sel_removeSelectedObjects_1,
- objects !is null ? objects.id_ : null) !is null;
- }
-
- public bool removeSelectionIndexes (NSIndexSet indexes)
- {
- return OS.objc_msgSend(this.id_, OS.sel_removeSelectionIndexes_1,
- indexes !is null ? indexes.id_ : null) !is null;
- }
-
- public void selectNext (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_selectNext_1,
- sender !is null ? sender.id_ : null);
- }
-
- public void selectPrevious (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_selectPrevious_1,
- sender !is null ? sender.id_ : null);
- }
-
- public NSArray selectedObjects ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedObjects);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSUInteger selectionIndex ()
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_selectionIndex);
- }
-
- public NSIndexSet selectionIndexes ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectionIndexes);
- return result !is null ? new NSIndexSet(result) : null;
- }
-
- public bool selectsInsertedObjects ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_selectsInsertedObjects) !is null;
- }
-
- public void setAlwaysUsesMultipleValuesMarker (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAlwaysUsesMultipleValuesMarker_1,
- flag);
- }
-
- public void setAutomaticallyRearrangesObjects (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAutomaticallyRearrangesObjects_1,
- flag);
- }
-
- public void setAvoidsEmptySelection (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAvoidsEmptySelection_1, flag);
- }
-
- public void setClearsFilterPredicateOnInsertion (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setClearsFilterPredicateOnInsertion_1,
- flag);
- }
-
- public void setFilterPredicate (NSPredicate filterPredicate)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFilterPredicate_1,
- filterPredicate !is null ? filterPredicate.id_ : null);
- }
-
- public void setPreservesSelection (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setPreservesSelection_1, flag);
- }
-
- public bool setSelectedObjects (NSArray objects)
- {
- return OS.objc_msgSend(this.id_, OS.sel_setSelectedObjects_1,
- objects !is null ? objects.id_ : null) !is null;
- }
-
- public bool setSelectionIndex (NSUInteger index)
- {
- return OS.objc_msgSend(this.id_, OS.sel_setSelectionIndex_1, index) !is null;
- }
-
- public bool setSelectionIndexes (NSIndexSet indexes)
- {
- return OS.objc_msgSend(this.id_, OS.sel_setSelectionIndexes_1,
- indexes !is null ? indexes.id_ : null) !is null;
- }
-
- public void setSelectsInsertedObjects (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setSelectsInsertedObjects_1, flag);
- }
-
- public void setSortDescriptors (NSArray sortDescriptors)
- {
- OS.objc_msgSend(this.id_, OS.sel_setSortDescriptors_1,
- sortDescriptors !is null ? sortDescriptors.id_ : null);
- }
-
- public NSArray sortDescriptors ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_sortDescriptors);
- return result !is null ? new NSArray(result) : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSAssertionHandler.d
--- a/dwt/internal/cocoa/NSAssertionHandler.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSAssertionHandler;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSAssertionHandler : NSObject
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public static NSAssertionHandler currentHandler ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSAssertionHandler, OS.sel_currentHandler);
- return result !is null ? new NSAssertionHandler(result) : null;
- }
-
- public void handleFailureInFunction (NSString functionName, NSString fileName, NSInteger line, NSString description)
- {
- OS.objc_msgSend(this.id_, OS.sel_handleFailureInFunction_1file_1lineNumber_1description_1, functionName !is null ? functionName.id_ : null,
- fileName !is null ? fileName.id_ : null, line, description !is null ? description.id_ : null);
- }
-
- public void handleFailureInMethod (objc.SEL selector, id object, NSString fileName, NSInteger line, NSString description)
- {
- OS.objc_msgSend(this.id_, OS.sel_handleFailureInMethod_1object_1file_1lineNumber_1description_1, selector, object !is null ? object.id_ : null,
- fileName !is null ? fileName.id_ : null, line, description !is null ? description.id_ : null);
- }
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSAttributedString.d
--- a/dwt/internal/cocoa/NSAttributedString.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSAttributedString.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,140 +1,96 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSAttributedString;
-import dwt.internal.cocoa.id;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSDictionary;
-import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSPoint;
import dwt.internal.cocoa.NSRange;
import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSSize;
-import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
-public class NSAttributedString : NSObject
-{
- public this ()
- {
- super();
- }
+public class NSAttributedString : NSObject {
- public this (objc.id id)
- {
- super(id);
- }
+public this() {
+ super();
+}
- public id attribute_atIndex_effectiveRange_ (NSString attrName, NSUInteger location, objc.id range)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attribute_1atIndex_1effectiveRange_1, attrName !is null ? attrName.id_ : null, location,
- range);
- return result !is null ? new id(result) : null;
- }
+public this(objc.id id) {
+ super(id);
+}
- public id attribute_atIndex_longestEffectiveRange_inRange_ (NSString attrName, NSUInteger location, objc.id range, NSRange rangeLimit)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attribute_1atIndex_1longestEffectiveRange_1inRange_1,
- attrName !is null ? attrName.id_ : null, location, range, rangeLimit);
- return result !is null ? new id(result) : null;
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public NSAttributedString attributedSubStringFromRange (NSRange range)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedSubStringFromRange_1, range);
- return result is this.id_ ? this : (result !is null ? new NSAttributedString(result) : null);
- }
-
- public NSDictionary attributesAtIndex_effectiveRange_ (int location, objc.id range)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributesAtIndex_1effectiveRange_1, location, range);
- return result !is null ? new NSDictionary(result) : null;
- }
+public NSDictionary attributesAtIndex(NSUInteger location, NSRangePointer range, NSRange rangeLimit) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesAtIndex_longestEffectiveRange_inRange_, location, range, rangeLimit);
+ return result !is null ? new NSDictionary(result) : null;
+}
- public NSDictionary attributesAtIndex_longestEffectiveRange_inRange_ (NSUInteger location, objc.id range, NSRange rangeLimit)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributesAtIndex_1longestEffectiveRange_1inRange_1, location, range, rangeLimit);
- return result !is null ? new NSDictionary(result) : null;
- }
+public NSRange doubleClickAtIndex(int /*long*/ location) {
+ NSRange result = NSRange();
+ OS.objc_msgSend_stret(result, this.id, OS.sel_doubleClickAtIndex_, location);
+ return result;
+}
- public NSAttributedString initWithAttributedString (NSAttributedString attrStr)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithAttributedString_1, attrStr !is null ? attrStr.id_ : null);
- return result !is null ? this : null;
- }
+public void drawAtPoint(NSPoint point) {
+ OS.objc_msgSend(this.id, OS.sel_drawAtPoint_, point);
+}
- public NSAttributedString initWithString_ (NSString str)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1, str !is null ? str.id_ : null);
- return result !is null ? this : null;
- }
+public void drawInRect(NSRect rect) {
+ OS.objc_msgSend(this.id, OS.sel_drawInRect_, rect);
+}
- public NSAttributedString initWithString_attributes_ (NSString str, NSDictionary attrs)
- {
- objc.id
- result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1attributes_1, str !is null ? str.id_ : null, attrs !is null ? attrs.id_ : null);
- return result !is null ? this : null;
- }
+public NSAttributedString initWithString(NSString str, NSDictionary attrs) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_attributes_, str !is null ? str.id : null, attrs !is null ? attrs.id : null);
+ return result is this.id ? this : (result !is null ? new NSAttributedString(result) : null);
+}
- public bool isEqualToAttributedString (NSAttributedString other)
- {
- return OS.objc_msgSend(this.id_, OS.sel_isEqualToAttributedString_1, other !is null ? other.id_ : null) !is null;
- }
+public int /*long*/ nextWordFromIndex(int /*long*/ location, bool isForward) {
+ return OS.objc_msgSend(this.id, OS.sel_nextWordFromIndex_forward_, location, isForward);
+}
- public NSUInteger length ()
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_length);
- }
-
- public NSString String ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_string);
- return result !is null ? new NSString(result) : null;
- }
+public NSSize size() {
+ NSSize result = NSSize();
+ OS.objc_msgSend_stret(result, this.id, OS.sel_size);
+ return result;
+}
- public NSSize size ()
- {
- NSSize result;
- OS.objc_msgSend_struct(&result, this.id_, OS.sel_size);
- return result;
- }
+public NSAttributedString attributedSubstringFromRange(NSRange range) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedSubstringFromRange_, range);
+ return result is this.id ? this : (result !is null ? new NSAttributedString(result) : null);
+}
- public void drawAtPoint (NSPoint pt)
- {
- OS.objc_msgSend(id_, OS.sel_drawAtPoint_, pt);
- }
-
- public void drawInRect (NSRect rect)
- {
- OS.objc_msgSend(id_, OS.sel_drawInRect_1, rect);
- }
+public NSAttributedString initWithString(NSString str) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_, str !is null ? str.id : null);
+ return result is this.id ? this : (result !is null ? new NSAttributedString(result) : null);
+}
- public void drawInRect (NSRect rect, objc.id options)
- {
- OS.objc_msgSend(id_, OS.sel_drawInRect_1, rect, options);
- }
+public NSUInteger length() {
+ return OS.objc_msgSend(this.id, OS.sel_length);
+}
- public NSUInteger nextWordFromIndex (NSUInteger index, bool forward)
- {
- return cast(NSUInteger) OS.objc_msgSend(id_, OS.sel_nextWordFromIndex_1forward_1, index, forward);
- }
+public NSString string() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_string);
+ return result !is null ? new NSString(result) : null;
+}
- public NSRange doubleClickAtIndex (NSUInteger index)
- {
- NSRange result;
- OS.objc_msgSend_struct(&result, id_, OS.sel_doubleClickAtIndex_1, index);
- return result;
- }
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSAutoreleasePool.d
--- a/dwt/internal/cocoa/NSAutoreleasePool.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSAutoreleasePool.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,105 +1,40 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSAutoreleasePool;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSInteger;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
-public class NSAutoreleasePool : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public static void static_addObject_ (id anObject)
- {
- OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_addObject_1, anObject !is null ? anObject.id_ : null);
- }
+public class NSAutoreleasePool : NSObject {
- public void addObject_ (id anObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_addObject_1, anObject !is null ? anObject.id_ : null);
- }
-
- public static NSUInteger autoreleasedObjectCount ()
- {
- return cast(NSUInteger) OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_autoreleasedObjectCount);
- }
-
- public void drain ()
- {
- OS.objc_msgSend(this.id_, OS.sel_drain);
- }
-
- public static void enableFreedObjectCheck (bool enable)
- {
- OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_enableFreedObjectCheck_1, enable);
- }
+public this() {
+ super();
+}
- public static void enableRelease (bool enable)
- {
- OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_enableRelease_1, enable);
- }
-
- public static NSUInteger poolCountHighWaterMark ()
- {
- return cast(NSUInteger) OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_poolCountHighWaterMark);
- }
-
- public static NSUInteger poolCountHighWaterResolution ()
- {
- return cast(NSUInteger) OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_poolCountHighWaterResolution);
- }
-
- public static void resetTotalAutoreleasedObjects ()
- {
- OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_resetTotalAutoreleasedObjects);
- }
+public this(objc.id id) {
+ super(id);
+}
- public static void setPoolCountHighWaterMark (NSUInteger count)
- {
- OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_setPoolCountHighWaterMark_1, count);
- }
-
- public static void setPoolCountHighWaterResolution (NSUInteger res)
- {
- OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_setPoolCountHighWaterResolution_1, res);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public static void showPools ()
- {
- OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_showPools);
- }
-
- public static NSUInteger topAutoreleasePoolCount ()
- {
- return cast(NSUInteger) OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_topAutoreleasePoolCount);
- }
-
- public static NSUInteger totalAutoreleasedObjects ()
- {
- return cast(NSUInteger) OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_totalAutoreleasedObjects);
- }
+public static void enableFreedObjectCheck(bool enable) {
+ OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_enableFreedObjectCheck_, enable);
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSBezierPath.d
--- a/dwt/internal/cocoa/NSBezierPath.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSBezierPath.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,26 +1,28 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSBezierPath;
-import dwt.internal.cocoa.CGFloat;
+import dwt.dwthelper.utils;
+import dwt.internal.c.Carbon;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSAffineTransform;
import dwt.internal.cocoa.NSFont;
-import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSPoint;
import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
enum NSBezierPathElement
@@ -31,11 +33,6 @@
NSClosePathBezierPathElement
}
-alias NSBezierPathElement.NSMoveToBezierPathElement NSMoveToBezierPathElement;
-alias NSBezierPathElement.NSLineToBezierPathElement NSLineToBezierPathElement;
-alias NSBezierPathElement.NSCurveToBezierPathElement NSCurveToBezierPathElement;
-alias NSBezierPathElement.NSClosePathBezierPathElement NSClosePathBezierPathElement;
-
enum NSLineCapStyle
{
NSButtLineCapStyle = 0,
@@ -43,10 +40,6 @@
NSSquareLineCapStyle = 2
}
-alias NSLineCapStyle.NSButtLineCapStyle NSButtLineCapStyle;
-alias NSLineCapStyle.NSRoundLineCapStyle NSRoundLineCapStyle;
-alias NSLineCapStyle.NSSquareLineCapStyle NSSquareLineCapStyle;
-
enum NSLineJoinStyle
{
NSMiterLineJoinStyle = 0,
@@ -54,402 +47,181 @@
NSBevelLineJoinStyle = 2
}
-alias NSLineJoinStyle.NSMiterLineJoinStyle NSMiterLineJoinStyle;
-alias NSLineJoinStyle.NSRoundLineJoinStyle NSRoundLineJoinStyle;
-alias NSLineJoinStyle.NSBevelLineJoinStyle NSBevelLineJoinStyle;
-
enum NSWindingRule
{
NSNonZeroWindingRule = 0,
NSEvenOddWindingRule = 1
}
-alias NSWindingRule.NSNonZeroWindingRule NSNonZeroWindingRule;
-alias NSWindingRule.NSEvenOddWindingRule NSEvenOddWindingRule;
-
-public class NSBezierPath : NSObject
-{
- public this ()
- {
- super();
- }
+public class NSBezierPath : NSObject {
- public this (objc.id id)
- {
- super(id);
- }
-
- public void addClip ()
- {
- OS.objc_msgSend(this.id_, OS.sel_addClip);
- }
+public this() {
+ super();
+}
- public void appendBezierPath (NSBezierPath path)
- {
- OS.objc_msgSend(this.id_, OS.sel_appendBezierPath_1, path !is null ? path.id_ : null);
- }
-
- public void appendBezierPathWithArcFromPoint (NSPoint point1, NSPoint point2, CGFloat radius)
- {
- OS.objc_msgSend(this.id_, OS.sel_appendBezierPathWithArcFromPoint_1toPoint_1radius_1, point1, point2, radius);
- }
+public this(objc.id id) {
+ super(id);
+}
- public void appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_ (NSPoint center, CGFloat radius, CGFloat startAngle, CGFloat endAngle)
- {
- OS.objc_msgSend(this.id_, OS.sel_appendBezierPathWithArcWithCenter_1radius_1startAngle_1endAngle_1, center, radius, startAngle, endAngle);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public void appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_ (NSPoint center, CGFloat radius, CGFloat startAngle,
- CGFloat endAngle, bool clockwise)
- {
- OS.objc_msgSend(this.id_, OS.sel_appendBezierPathWithArcWithCenter_1radius_1startAngle_1endAngle_1clockwise_1, center, radius, startAngle,
- endAngle, clockwise);
- }
-
- public void appendBezierPathWithGlyph (NSGlyph glyph, NSFont font)
- {
- OS.objc_msgSend(this.id_, OS.sel_appendBezierPathWithGlyph_1inFont_1, glyph, font !is null ? font.id_ : null);
- }
+public void addClip() {
+ OS.objc_msgSend(this.id, OS.sel_addClip);
+}
- public void appendBezierPathWithGlyphs (NSGlyph* glyphs, NSInteger count, NSFont font)
- {
- OS.objc_msgSend(this.id_, OS.sel_appendBezierPathWithGlyphs_1count_1inFont_1, glyphs, count, font !is null ? font.id_ : null);
- }
-
- public void appendBezierPathWithOvalInRect (NSRect rect)
- {
- OS.objc_msgSend(this.id_, OS.sel_appendBezierPathWithOvalInRect_1, rect);
- }
+public void appendBezierPath(NSBezierPath path) {
+ OS.objc_msgSend(this.id, OS.sel_appendBezierPath_, path !is null ? path.id : null);
+}
- public void appendBezierPathWithPackedGlyphs (/*const*/char* packedGlyphs)
- {
- OS.objc_msgSend(this.id_, OS.sel_appendBezierPathWithPackedGlyphs_1, packedGlyphs);
- }
-
- public void appendBezierPathWithPoints (NSPointArray points, NSInteger count)
- {
- OS.objc_msgSend(this.id_, OS.sel_appendBezierPathWithPoints_1count_1, points, count);
- }
+public void appendBezierPathWithArcWithCenter(NSPoint center, CGFloat radius, CGFloat startAngle, CGFloat endAngle) {
+ OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_, center, radius, startAngle, endAngle);
+}
- public void appendBezierPathWithRect (NSRect rect)
- {
- OS.objc_msgSend(this.id_, OS.sel_appendBezierPathWithRect_1, rect);
- }
-
- public void appendBezierPathWithRoundedRect (NSRect rect, CGFloat xRadius, CGFloat yRadius)
- {
- OS.objc_msgSend(this.id_, OS.sel_appendBezierPathWithRoundedRect_1xRadius_1yRadius_1, rect, xRadius, yRadius);
- }
+public void appendBezierPathWithArcWithCenter(NSPoint center, CGFloat radius, CGFloat startAngle, CGFloat endAngle, bool clockwise) {
+ OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_, center, radius, startAngle, endAngle, clockwise);
+}
- public static NSBezierPath bezierPath ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPath);
- return result !is null ? new NSBezierPath(result) : null;
- }
+public void appendBezierPathWithGlyphs(NSGlyph* glyphs, NSInteger count, NSFont font) {
+ OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithGlyphs_count_inFont_, glyphs, count, font !is null ? font.id : null);
+}
- public NSBezierPath bezierPathByFlatteningPath ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_bezierPathByFlatteningPath);
- return result is this.id_ ? this : (result !is null ? new NSBezierPath(result) : null);
- }
-
- public NSBezierPath bezierPathByReversingPath ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_bezierPathByReversingPath);
- return result is this.id_ ? this : (result !is null ? new NSBezierPath(result) : null);
- }
+public void appendBezierPathWithOvalInRect(NSRect rect) {
+ OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithOvalInRect_, rect);
+}
- public static NSBezierPath bezierPathWithOvalInRect (NSRect rect)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithOvalInRect_1, rect);
- return result !is null ? new NSBezierPath(result) : null;
- }
+public void appendBezierPathWithRect(NSRect rect) {
+ OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithRect_, rect);
+}
- public static NSBezierPath bezierPathWithRect (NSRect rect)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithRect_1, rect);
- return result !is null ? new NSBezierPath(result) : null;
- }
-
- public static NSBezierPath bezierPathWithRoundedRect (NSRect rect, CGFloat xRadius, CGFloat yRadius)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithRoundedRect_1xRadius_1yRadius_1, rect, xRadius, yRadius);
- return result !is null ? new NSBezierPath(result) : null;
- }
+public void appendBezierPathWithRoundedRect(NSRect rect, CGFloat xRadius, CGFloat yRadius) {
+ OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithRoundedRect_xRadius_yRadius_, rect, xRadius, yRadius);
+}
- public NSRect bounds ()
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_bounds);
- return result;
- }
-
- public bool cachesBezierPath ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_cachesBezierPath) !is null;
- }
+public static NSBezierPath bezierPath() {
+ objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPath);
+ return result !is null ? new NSBezierPath(result) : null;
+}
- public static void clipRect (NSRect rect)
- {
- OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_clipRect_1, rect);
- }
-
- public void closePath ()
- {
- OS.objc_msgSend(this.id_, OS.sel_closePath);
- }
-
- public bool containsPoint (NSPoint point)
- {
- return OS.objc_msgSend(this.id_, OS.sel_containsPoint_1, point) !is null;
- }
+public NSBezierPath bezierPathByFlatteningPath() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_bezierPathByFlatteningPath);
+ return result is this.id ? this : (result !is null ? new NSBezierPath(result) : null);
+}
- public NSRect controlPointBounds ()
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_controlPointBounds);
- return result;
- }
+public static NSBezierPath bezierPathWithRect(NSRect rect) {
+ objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithRect_, rect);
+ return result !is null ? new NSBezierPath(result) : null;
+}
- public NSPoint currentPoint ()
- {
- NSPoint result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_currentPoint);
- return result;
- }
-
- public void curveToPoint (NSPoint endPoint, NSPoint controlPoint1, NSPoint controlPoint2)
- {
- OS.objc_msgSend(this.id_, OS.sel_curveToPoint_1controlPoint1_1controlPoint2_1, endPoint, controlPoint1, controlPoint2);
- }
-
- public static CGFloat defaultFlatness ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultFlatness);
- }
+public NSRect bounds() {
+ NSRect result = NSRect();
+ OS.objc_msgSend_stret(result, this.id, OS.sel_bounds);
+ return result;
+}
- public static NSLineCapStyle defaultLineCapStyle ()
- {
- return cast(NSLineCapStyle) OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultLineCapStyle);
- }
-
- public static NSLineJoinStyle defaultLineJoinStyle ()
- {
- return cast(NSLineJoinStyle) OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultLineJoinStyle);
- }
-
- public static CGFloat defaultLineWidth ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultLineWidth);
- }
+public void closePath() {
+ OS.objc_msgSend(this.id, OS.sel_closePath);
+}
- public static CGFloat defaultMiterLimit ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultMiterLimit);
- }
+public bool containsPoint(NSPoint point) {
+ return OS.objc_msgSend_bool(this.id, OS.sel_containsPoint_, point);
+}
- public static NSWindingRule defaultWindingRule ()
- {
- return cast(NSWindingRule) OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultWindingRule);
- }
-
- public static void drawPackedGlyphs (/*const*/char* packedGlyphs, NSPoint point)
- {
- OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_drawPackedGlyphs_1atPoint_1, packedGlyphs, point);
- }
+public NSRect controlPointBounds() {
+ NSRect result = NSRect();
+ OS.objc_msgSend_stret(result, this.id, OS.sel_controlPointBounds);
+ return result;
+}
- public NSBezierPathElement elementAtIndex_ (NSInteger index)
- {
- return cast(NSBezierPathElement) OS.objc_msgSend(this.id_, OS.sel_elementAtIndex_1, index);
- }
-
- public NSBezierPathElement elementAtIndex_associatedPoints_ (NSInteger index, NSPointArray points)
- {
- return cast(NSBezierPathElement) OS.objc_msgSend(this.id_, OS.sel_elementAtIndex_1associatedPoints_1, index, points);
- }
+public NSPoint currentPoint() {
+ NSPoint result = NSPoint();
+ OS.objc_msgSend_stret(result, this.id, OS.sel_currentPoint);
+ return result;
+}
- public NSInteger elementCount ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_elementCount);
- }
-
- public void fill ()
- {
- OS.objc_msgSend(this.id_, OS.sel_fill);
- }
+public void curveToPoint(NSPoint endPoint, NSPoint controlPoint1, NSPoint controlPoint2) {
+ OS.objc_msgSend(this.id, OS.sel_curveToPoint_controlPoint1_controlPoint2_, endPoint, controlPoint1, controlPoint2);
+}
- public static void fillRect (NSRect rect)
- {
- OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_fillRect_1, rect);
- }
-
- public CGFloat flatness ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_flatness);
- }
+public static CGFloat defaultFlatness() {
+ return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultFlatness);
+}
- public void getLineDash (CGFloat* pattern, NSInteger* count, CGFloat* phase)
- {
- OS.objc_msgSend(this.id_, OS.sel_getLineDash_1count_1phase_1, pattern, count, phase);
- }
+public NSBezierPathElement elementAtIndex(NSInteger index, NSPointArray points) {
+ return cast(NSBezierPathElement) OS.objc_msgSend(this.id, OS.sel_elementAtIndex_associatedPoints_, index, points);
+}
- public bool isEmpty ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isEmpty) !is null;
- }
-
- public NSLineCapStyle lineCapStyle ()
- {
- return cast(NSLineCapStyle) OS.objc_msgSend(this.id_, OS.sel_lineCapStyle);
- }
+public NSInteger elementCount() {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_elementCount);
+}
- public NSLineJoinStyle lineJoinStyle ()
- {
- return cast(NSLineJoinStyle) OS.objc_msgSend(this.id_, OS.sel_lineJoinStyle);
- }
-
- public void lineToPoint (NSPoint point)
- {
- OS.objc_msgSend(this.id_, OS.sel_lineToPoint_1, point);
- }
+public void fill() {
+ OS.objc_msgSend(this.id, OS.sel_fill);
+}
- public CGFloat lineWidth ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_lineWidth);
- }
+public static void fillRect(NSRect rect) {
+ OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_fillRect_, rect);
+}
- public CGFloat miterLimit ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_miterLimit);
- }
-
- public void moveToPoint (NSPoint point)
- {
- OS.objc_msgSend(this.id_, OS.sel_moveToPoint_1, point);
- }
+public bool isEmpty() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_isEmpty);
+}
- public void relativeCurveToPoint (NSPoint endPoint, NSPoint controlPoint1, NSPoint controlPoint2)
- {
- OS.objc_msgSend(this.id_, OS.sel_relativeCurveToPoint_1controlPoint1_1controlPoint2_1, endPoint, controlPoint1, controlPoint2);
- }
-
- public void relativeLineToPoint (NSPoint point)
- {
- OS.objc_msgSend(this.id_, OS.sel_relativeLineToPoint_1, point);
- }
+public void lineToPoint(NSPoint point) {
+ OS.objc_msgSend(this.id, OS.sel_lineToPoint_, point);
+}
- public void relativeMoveToPoint (NSPoint point)
- {
- OS.objc_msgSend(this.id_, OS.sel_relativeMoveToPoint_1, point);
- }
+public void moveToPoint(NSPoint point) {
+ OS.objc_msgSend(this.id, OS.sel_moveToPoint_, point);
+}
- public void removeAllPoints ()
- {
- OS.objc_msgSend(this.id_, OS.sel_removeAllPoints);
- }
-
- public void setAssociatedPoints (NSPointArray points, NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAssociatedPoints_1atIndex_1, points, index);
- }
+public void removeAllPoints() {
+ OS.objc_msgSend(this.id, OS.sel_removeAllPoints);
+}
- public void setCachesBezierPath (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCachesBezierPath_1, flag);
- }
-
- public void setClip ()
- {
- OS.objc_msgSend(this.id_, OS.sel_setClip);
- }
+public void setClip() {
+ OS.objc_msgSend(this.id, OS.sel_setClip);
+}
- public static void setDefaultFlatness (CGFloat flatness)
- {
- OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultFlatness_1, flatness);
- }
-
- public static void setDefaultLineCapStyle (NSLineCapStyle lineCapStyle)
- {
- OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineCapStyle_1, lineCapStyle);
- }
-
- public static void setDefaultLineJoinStyle (NSLineJoinStyle lineJoinStyle)
- {
- OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineJoinStyle_1, lineJoinStyle);
- }
+public static void setDefaultFlatness(CGFloat flatness) {
+ OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultFlatness_, flatness);
+}
- public static void setDefaultLineWidth (CGFloat lineWidth)
- {
- OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineWidth_1, lineWidth);
- }
-
- public static void setDefaultMiterLimit (CGFloat limit)
- {
- OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultMiterLimit_1, limit);
- }
+public void setLineCapStyle(NSLineCapStyle lineCapStyle) {
+ OS.objc_msgSend(this.id, OS.sel_setLineCapStyle_, lineCapStyle);
+}
- public static void setDefaultWindingRule (NSWindingRule windingRule)
- {
- OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultWindingRule_1, windingRule);
- }
+public void setLineDash(/*const*/CGFloat* pattern, NSInteger count, CGFloat phase) {
+ OS.objc_msgSend(this.id, OS.sel_setLineDash_count_phase_, pattern, count, phase);
+}
- public void setFlatness (CGFloat flatness)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFlatness_1, flatness);
- }
-
- public void setLineCapStyle (NSLineCapStyle lineCapStyle)
- {
- OS.objc_msgSend(this.id_, OS.sel_setLineCapStyle_1, lineCapStyle);
- }
+public void setLineJoinStyle(NSLineJoinStyle lineJoinStyle) {
+ OS.objc_msgSend(this.id, OS.sel_setLineJoinStyle_, lineJoinStyle);
+}
- public void setLineDash (/*const*/CGFloat* pattern, NSInteger count, CGFloat phase)
- {
- OS.objc_msgSend(this.id_, OS.sel_setLineDash_1count_1phase_1, pattern, count, phase);
- }
-
- public void setLineJoinStyle (NSLineJoinStyle lineJoinStyle)
- {
- OS.objc_msgSend(this.id_, OS.sel_setLineJoinStyle_1, lineJoinStyle);
- }
+public void setLineWidth(CGFloat lineWidth) {
+ OS.objc_msgSend(this.id, OS.sel_setLineWidth_, lineWidth);
+}
- public void setLineWidth (CGFloat lineWidth)
- {
- OS.objc_msgSend(this.id_, OS.sel_setLineWidth_1, lineWidth);
- }
+public void setMiterLimit(CGFloat miterLimit) {
+ OS.objc_msgSend(this.id, OS.sel_setMiterLimit_, miterLimit);
+}
- public void setMiterLimit (CGFloat miterLimit)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMiterLimit_1, miterLimit);
- }
-
- public void setWindingRule (NSWindingRule windingRule)
- {
- OS.objc_msgSend(this.id_, OS.sel_setWindingRule_1, windingRule);
- }
+public void setWindingRule(NSWindingRule windingRule) {
+ OS.objc_msgSend(this.id, OS.sel_setWindingRule_, windingRule);
+}
- public void stroke ()
- {
- OS.objc_msgSend(this.id_, OS.sel_stroke);
- }
-
- public static void strokeLineFromPoint (NSPoint point1, NSPoint point2)
- {
- OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_strokeLineFromPoint_1toPoint_1, point1, point2);
- }
+public void stroke() {
+ OS.objc_msgSend(this.id, OS.sel_stroke);
+}
- public static void strokeRect (NSRect rect)
- {
- OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_strokeRect_1, rect);
- }
+public static void strokeRect(NSRect rect) {
+ OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_strokeRect_, rect);
+}
- public void transformUsingAffineTransform (NSAffineTransform transform)
- {
- OS.objc_msgSend(this.id_, OS.sel_transformUsingAffineTransform_1, transform !is null ? transform.id_ : null);
- }
+public void transformUsingAffineTransform(NSAffineTransform transform) {
+ OS.objc_msgSend(this.id, OS.sel_transformUsingAffineTransform_, transform !is null ? transform.id : null);
+}
- public NSWindingRule windingRule ()
- {
- return cast(NSWindingRule) OS.objc_msgSend(this.id_, OS.sel_windingRule);
- }
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSBitmapImageRep.d
--- a/dwt/internal/cocoa/NSBitmapImageRep.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSBitmapImageRep.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,34 +1,32 @@
-/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSBitmapImageRep;
-import dwt.internal.cocoa.CGFloat;
-import dwt.internal.cocoa.CIImage;
-import dwt.internal.cocoa.id;
+import dwt.internal.c.Carbon;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSColor;
import dwt.internal.cocoa.NSData;
import dwt.internal.cocoa.NSDictionary;
import dwt.internal.cocoa.NSImageRep;
-import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
-enum NSTIFFCompression : NSUInteger
-{
+enum NSTIFFCompression : NSUInteger {
NSTIFFCompressionNone = 1,
NSTIFFCompressionCCITTFAX3 = 3,
NSTIFFCompressionCCITTFAX4 = 4,
@@ -39,260 +37,59 @@
NSTIFFCompressionOldJPEG = 32865
}
-alias NSTIFFCompression.NSTIFFCompressionNone NSTIFFCompressionNone;
-alias NSTIFFCompression.NSTIFFCompressionCCITTFAX3 NSTIFFCompressionCCITTFAX3;
-alias NSTIFFCompression.NSTIFFCompressionCCITTFAX4 NSTIFFCompressionCCITTFAX4;
-alias NSTIFFCompression.NSTIFFCompressionLZW NSTIFFCompressionLZW;
-alias NSTIFFCompression.NSTIFFCompressionJPEG NSTIFFCompressionJPEG;
-alias NSTIFFCompression.NSTIFFCompressionNEXT NSTIFFCompressionNEXT;
-alias NSTIFFCompression.NSTIFFCompressionPackBits NSTIFFCompressionPackBits;
-alias NSTIFFCompression.NSTIFFCompressionOldJPEG NSTIFFCompressionOldJPEG;
-
-enum NSBitmapFormat : NSUInteger
-{
+enum NSBitmapFormat : NSUInteger {
NSAlphaFirstBitmapFormat = 1 << 0,
NSAlphaNonpremultipliedBitmapFormat = 1 << 1,
NSFloatingPointSamplesBitmapFormat = 1 << 2
}
-alias NSBitmapFormat.NSAlphaFirstBitmapFormat NSAlphaFirstBitmapFormat;
-alias NSBitmapFormat.NSAlphaNonpremultipliedBitmapFormat NSAlphaNonpremultipliedBitmapFormat;
-alias NSBitmapFormat.NSFloatingPointSamplesBitmapFormat NSFloatingPointSamplesBitmapFormat;
-
-public class NSBitmapImageRep : NSImageRep
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public objc.id CGImage ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_CGImage);
- }
-
- public NSData TIFFRepresentation ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_TIFFRepresentation);
- return result !is null ? new NSData(result) : null;
- }
+public class NSBitmapImageRep : NSImageRep {
+
+public this () {
+ super();
+}
- public static NSData static_TIFFRepresentationOfImageRepsInArray_ (NSArray array)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_TIFFRepresentationOfImageRepsInArray_1, array !is null ? array.id_ : null);
- return result !is null ? new NSData(result) : null;
- }
-
- public static NSData static_TIFFRepresentationOfImageRepsInArray_usingCompression_factor_ (NSArray array, objc.id comp, float factor)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_TIFFRepresentationOfImageRepsInArray_1usingCompression_1factor_1,
- array !is null ? array.id_ : null, comp, factor);
- return result !is null ? new NSData(result) : null;
- }
-
- public NSData TIFFRepresentationUsingCompression (objc.id comp, float factor)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_TIFFRepresentationUsingCompression_1factor_1, comp, factor);
- return result !is null ? new NSData(result) : null;
- }
-
- public objc.id bitmapData ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_bitmapData);
- }
-
- public objc.id bitmapFormat ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_bitmapFormat);
- }
+public this (objc.id id) {
+ super(id);
+}
- public NSInteger bitsPerPixel ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_bitsPerPixel);
- }
-
- public NSInteger bytesPerPlane ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_bytesPerPlane);
- }
+public this (cocoa.id id) {
+ super(id);
- public NSInteger bytesPerRow ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_bytesPerRow);
- }
-
- public bool canBeCompressedUsing (objc.id compression)
- {
- return OS.objc_msgSend(this.id_, OS.sel_canBeCompressedUsing_1, compression) !is null;
- }
-
- public NSColor colorAtX (NSInteger x, NSInteger y)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_colorAtX_1y_1, x, y);
- return result !is null ? new NSColor(result) : null;
- }
+}
- public void colorizeByMappingGray (CGFloat midPoint, NSColor midPointColor, NSColor shadowColor, NSColor lightColor)
- {
- OS.objc_msgSend(this.id_, OS.sel_colorizeByMappingGray_1toColor_1blackMapping_1whiteMapping_1, midPoint,
- midPointColor !is null ? midPointColor.id_ : null, shadowColor !is null ? shadowColor.id_ : null,
- lightColor !is null ? lightColor.id_ : null);
- }
-
- public void getBitmapDataPlanes (objc.id data)
- {
- OS.objc_msgSend(this.id_, OS.sel_getBitmapDataPlanes_1, data);
- }
-
- public void getCompression (NSTIFFCompression* compression, float* factor)
- {
- OS.objc_msgSend(this.id_, OS.sel_getCompression_1factor_1, compression, factor);
- }
+public objc.id bitmapData () {
+ return OS.objc_msgSend(this.id, OS.sel_bitmapData);
+}
- public void getPixel (/*NSUInteger[]*/NSUInteger* p, NSInteger x, NSInteger y)
- {
- OS.objc_msgSend(this.id_, OS.sel_getPixel_1atX_1y_1, p, x, y);
- }
-
- public static void getTIFFCompressionTypes (/*const*/NSTIFFCompression** list, NSInteger* numTypes)
- {
- OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_getTIFFCompressionTypes_1count_1, list, numTypes);
- }
-
- public static id imageRepWithData (NSData data)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_imageRepWithData_1, data !is null ? data.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static NSArray imageRepsWithData (NSData data)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_imageRepsWithData_1, data !is null ? data.id_ : null);
- return result !is null ? new NSArray(result) : null;
- }
+public NSInteger bitsPerPixel () {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_bitsPerPixel);
+}
- public NSInteger incrementalLoadFromData (NSData data, bool complete)
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_incrementalLoadFromData_1complete_1, data !is null ? data.id_ : null, complete);
- }
-
- public NSBitmapImageRep initForIncrementalLoad ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initForIncrementalLoad);
- return result !is null ? this : null;
- }
-
- public NSBitmapImageRep initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_ (
- ubyte** planes, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, bool alpha, bool isPlanar, NSString colorSpaceName,
- NSBitmapFormat bitmapFormat, NSInteger rBytes, NSInteger pBits)
- {
- objc.id
- result = OS.objc_msgSend(
- this.id_,
- OS.sel_initWithBitmapDataPlanes_1pixelsWide_1pixelsHigh_1bitsPerSample_1samplesPerPixel_1hasAlpha_1isPlanar_1colorSpaceName_1bitmapFormat_1bytesPerRow_1bitsPerPixel_1,
- planes, width, height, bps, spp, alpha, isPlanar, colorSpaceName !is null ? colorSpaceName.id_ : null, bitmapFormat, rBytes,
- pBits);
- return result !is null ? this : null;
- }
+public NSInteger bytesPerPlane () {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_bytesPerPlane);
+}
- public NSBitmapImageRep initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_ (
- ubyte** planes, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, bool alpha, bool isPlanar, NSString colorSpaceName, NSInteger rBytes, NSInteger pBits)
- {
- objc.id
- result = OS.objc_msgSend(
- this.id_,
- OS.sel_initWithBitmapDataPlanes_1pixelsWide_1pixelsHigh_1bitsPerSample_1samplesPerPixel_1hasAlpha_1isPlanar_1colorSpaceName_1bytesPerRow_1bitsPerPixel_1,
- planes, width, height, bps, spp, alpha, isPlanar, colorSpaceName !is null ? colorSpaceName.id_ : null, rBytes, pBits);
- return result !is null ? this : null;
- }
-
- public NSBitmapImageRep initWithCGImage (objc.id cgImage)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithCGImage_1, cgImage);
- return result !is null ? this : null;
- }
+public NSInteger bytesPerRow () {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_bytesPerRow);
+}
- public NSBitmapImageRep initWithCIImage (CIImage ciImage)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithCIImage_1, ciImage !is null ? ciImage.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSBitmapImageRep initWithData (NSData data)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithData_1, data !is null ? data.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSBitmapImageRep initWithFocusedViewRect (NSRect rect)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithFocusedViewRect_1, rect);
- return result !is null ? this : null;
- }
+public NSBitmapImageRep initWithBitmapDataPlanes (ubyte** planes, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, bool alpha, bool isPlanar, NSString colorSpaceName, NSBitmapFormat bitmapFormat, NSInteger rBytes, NSInteger pBits) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_, planes, width, height, bps, spp, alpha, isPlanar, colorSpaceName !is null ? colorSpaceName.id : null, bitmapFormat, rBytes, pBits);
+ return result !is null ? this : null;
+}
- public bool isPlanar ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isPlanar) !is null;
- }
-
- public static NSString localizedNameForTIFFCompressionType (objc.id compression)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_localizedNameForTIFFCompressionType_1, compression);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSInteger numberOfPlanes ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfPlanes);
- }
-
- public static NSData representationOfImageRepsInArray (NSArray imageReps, objc.id storageType, NSDictionary properties)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_representationOfImageRepsInArray_1usingType_1properties_1,
- imageReps !is null ? imageReps.id_ : null, storageType, properties !is null ? properties.id_ : null);
- return result !is null ? new NSData(result) : null;
- }
-
- public NSData representationUsingType (objc.id storageType, NSDictionary properties)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_representationUsingType_1properties_1, storageType,
- properties !is null ? properties.id_ : null);
- return result !is null ? new NSData(result) : null;
- }
+public NSBitmapImageRep initWithBitmapDataPlanes (ubyte** planes, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, bool alpha, bool isPlanar, NSString colorSpaceName, NSInteger rBytes, NSInteger pBits) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_, planes, width, height, bps, spp, alpha, isPlanar, colorSpaceName !is null ? colorSpaceName.id : null, rBytes, pBits);
+ return result !is null ? this : null;
+}
- public NSInteger samplesPerPixel ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_samplesPerPixel);
- }
-
- public void setColor (NSColor color, NSInteger x, NSInteger y)
- {
- OS.objc_msgSend(this.id_, OS.sel_setColor_1atX_1y_1, color !is null ? color.id_ : null, x, y);
- }
-
- public void setCompression (NSTIFFCompression compression, float factor)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCompression_1factor_1, compression, factor);
- }
+public bool isPlanar () {
+ return OS.objc_msgSend_bool(this.id, OS.sel_isPlanar);
+}
- public void setPixel (/*NSUInteger[]*/NSUInteger* p, NSInteger x, NSInteger y)
- {
- OS.objc_msgSend(this.id_, OS.sel_setPixel_1atX_1y_1, p, x, y);
- }
+public NSInteger samplesPerPixel () {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_samplesPerPixel);
+}
- public void setProperty (NSString property, id value)
- {
- OS.objc_msgSend(this.id_, OS.sel_setProperty_1withValue_1, property !is null ? property.id_ : null, value !is null ? value.id_ : null);
- }
-
- public id valueForProperty (NSString property)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_valueForProperty_1, property !is null ? property.id_ : null);
- return result !is null ? new id(result) : null;
- }
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSBox.d
--- a/dwt/internal/cocoa/NSBox.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSBox.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,34 +1,34 @@
-/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSBox;
-import dwt.internal.cocoa.CGFloat;
+import dwt.internal.c.Carbon;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSCell;
import dwt.internal.cocoa.NSColor;
import dwt.internal.cocoa.NSFont;
-import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSSize;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
alias NSUInteger NSBoxType;
-enum
-{
+enum {
NSBoxPrimary = 0,
NSBoxSecondary = 1,
NSBoxSeparator = 2,
@@ -36,8 +36,7 @@
NSBoxCustom = 4
}
-enum NSTitlePosition
-{
+enum NSTitlePosition {
NSNoTitle = 0,
NSAboveTop = 1,
NSAtTop = 2,
@@ -47,177 +46,68 @@
NSBelowBottom = 6
}
-public class NSBox : NSView
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSColor borderColor ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_borderColor);
- return result !is null ? new NSColor(result) : null;
- }
+public class NSBox : NSView {
+
+public this () {
+ super();
+}
- public NSRect borderRect ()
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_borderRect);
- return result;
- }
+public this (objc.id id) {
+ super(id);
+}
- public NSBorderType borderType ()
- {
- return cast(NSBorderType) OS.objc_msgSend(this.id_, OS.sel_borderType);
- }
-
- public CGFloat borderWidth ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_borderWidth);
- }
-
- public NSBoxType boxType ()
- {
- return cast(NSBoxType) OS.objc_msgSend(this.id_, OS.sel_boxType);
- }
+public this (cocoa.id id) {
+ super(id);
+}
- public NSView contentView ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_contentView);
- return result !is null ? new NSView(result) : null;
- }
-
- public NSSize contentViewMargins ()
- {
- NSSize result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_contentViewMargins);
- return result;
- }
-
- public CGFloat cornerRadius ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_cornerRadius);
- }
+public CGFloat borderWidth () {
+ return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_borderWidth);
+}
- public NSColor fillColor ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_fillColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public bool isTransparent ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isTransparent) !is null;
- }
+public NSSize contentViewMargins () {
+ NSSize result;
+ OS.objc_msgSend_stret(result, this.id, OS.sel_contentViewMargins);
+ return result;
+}
- public void setBorderColor (NSColor borderColor)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBorderColor_1, borderColor !is null ? borderColor.id_ : null);
- }
+public void setBorderType (NSBorderType aType) {
+ OS.objc_msgSend(this.id, OS.sel_setBorderType_1, aType);
+}
- public void setBorderType (NSBorderType aType)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBorderType_1, aType);
- }
-
- public void setBorderWidth (CGFloat borderWidth)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBorderWidth_1, borderWidth);
- }
+public void setBorderWidth (CGFloat borderWidth) {
+ OS.objc_msgSend(this.id, OS.sel_setBorderWidth_1, borderWidth);
+}
- public void setBoxType (NSBoxType boxType)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBoxType_1, boxType);
- }
-
- public void setContentView (NSView aView)
- {
- OS.objc_msgSend(this.id_, OS.sel_setContentView_1, aView !is null ? aView.id_ : null);
- }
+public void setBoxType (NSBoxType boxType) {
+ OS.objc_msgSend(this.id, OS.sel_setBoxType_1, boxType);
+}
- public void setContentViewMargins (NSSize offsetSize)
- {
- OS.objc_msgSend(this.id_, OS.sel_setContentViewMargins_1, offsetSize);
- }
-
- public void setCornerRadius (CGFloat cornerRadius)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCornerRadius_1, cornerRadius);
- }
+public void setContentView (NSView aView) {
+ OS.objc_msgSend(this.id, OS.sel_setContentView_, aView !is null ? aView.id : null);
+}
- public void setFillColor (NSColor fillColor)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFillColor_1, fillColor !is null ? fillColor.id_ : null);
- }
-
- public void setFrameFromContentFrame (NSRect contentFrame)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFrameFromContentFrame_1, contentFrame);
- }
+public void setContentViewMargins (NSSize offsetSize) {
+ OS.objc_msgSend(this.id, OS.sel_setContentViewMargins_, offsetSize);
+}
- public void setTitle (NSString aString)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTitle_1, aString !is null ? aString.id_ : null);
- }
-
- public void setTitleFont (NSFont fontObj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTitleFont_1, fontObj !is null ? fontObj.id_ : null);
- }
-
- public void setTitlePosition (NSTitlePosition aPosition)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTitlePosition_1, aPosition);
- }
+public void setTitle (NSString aString) {
+ OS.objc_msgSend(this.id, OS.sel_setTitle_, aString !is null ? aString.id : null);
+}
- public void setTitleWithMnemonic (NSString StringWithAmpersand)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTitleWithMnemonic_1, StringWithAmpersand !is null ? StringWithAmpersand.id_ : null);
- }
-
- public void setTransparent (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTransparent_1, flag);
- }
+public void setTitleFont (NSFont fontObj) {
+ OS.objc_msgSend(this.id, OS.sel_setTitleFont_, fontObj !is null ? fontObj.id : null);
+}
- public void sizeToFit ()
- {
- OS.objc_msgSend(this.id_, OS.sel_sizeToFit);
- }
-
- public NSString title ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_title);
- return result !is null ? new NSString(result) : null;
- }
+public void setTitlePosition (NSTitlePosition aPosition) {
+ OS.objc_msgSend(this.id, OS.sel_setTitlePosition_, aPosition);
+}
- public NSCell titleCell ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_titleCell);
- return result !is null ? new NSCell(result) : null;
- }
-
- public NSFont titleFont ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_titleFont);
- return result !is null ? new NSFont(result) : null;
- }
+public void sizeToFit () {
+ OS.objc_msgSend(this.id, OS.sel_sizeToFit);
+}
- public NSTitlePosition titlePosition ()
- {
- return cast(NSTitlePosition) OS.objc_msgSend(this.id_, OS.sel_titlePosition);
- }
-
- public NSRect titleRect ()
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_titleRect);
- return result;
- }
+public NSCell titleCell () {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_titleCell);
+ return result !is null ? new NSCell(result) : null;
}
+}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSBrowser.d
--- a/dwt/internal/cocoa/NSBrowser.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,552 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSBrowser;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.CGFloat;
-import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSCell;
-import dwt.internal.cocoa.NSColor;
-import dwt.internal.cocoa.NSControl;
-import dwt.internal.cocoa.NSEvent;
-import dwt.internal.cocoa.NSImage;
-import dwt.internal.cocoa.NSIndexSet;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSMatrix;
-import dwt.internal.cocoa.NSPoint : NSPointPointer;
-import dwt.internal.cocoa.NSRect;
-import dwt.internal.cocoa.NSScroller;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSBrowser : NSControl
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public bool acceptsArrowKeys ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_acceptsArrowKeys) !is null;
- }
-
- public void addColumn ()
- {
- OS.objc_msgSend(this.id_, OS.sel_addColumn);
- }
-
- public bool allowsBranchSelection ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_allowsBranchSelection) !is null;
- }
-
- public bool allowsEmptySelection ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_allowsEmptySelection) !is null;
- }
-
- public bool allowsMultipleSelection ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_allowsMultipleSelection) !is null;
- }
-
- public bool allowsTypeSelect ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_allowsTypeSelect) !is null;
- }
-
- public NSColor backgroundColor ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_backgroundColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public bool canDragRowsWithIndexes (NSIndexSet rowIndexes, NSInteger column, NSEvent event)
- {
- return OS.objc_msgSend(this.id_, OS.sel_canDragRowsWithIndexes_1inColumn_1withEvent_1, rowIndexes !is null ? rowIndexes.id_ : null, column,
- event !is null ? event.id_ : null) !is null;
- }
-
- public static objc.Class cellClass ()
- {
- return cast(objc.Class) OS.objc_msgSend(OS.class_NSBrowser, OS.sel_cellClass);
- }
-
- public id cellPrototype ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_cellPrototype);
- return result !is null ? new id(result) : null;
- }
-
- public CGFloat columnContentWidthForColumnWidth (CGFloat columnWidth)
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_columnContentWidthForColumnWidth_1, columnWidth);
- }
-
- public NSInteger columnOfMatrix (NSMatrix matrix)
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_columnOfMatrix_1, matrix !is null ? matrix.id_ : null);
- }
-
- public objc.id columnResizingType ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_columnResizingType);
- }
-
- public CGFloat columnWidthForColumnContentWidth (CGFloat columnContentWidth)
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_columnWidthForColumnContentWidth_1, columnContentWidth);
- }
-
- public NSString columnsAutosaveName ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_columnsAutosaveName);
- return result !is null ? new NSString(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 void displayAllColumns ()
- {
- OS.objc_msgSend(this.id_, OS.sel_displayAllColumns);
- }
-
- public void displayColumn (NSInteger column)
- {
- OS.objc_msgSend(this.id_, OS.sel_displayColumn_1, column);
- }
-
- public void doClick (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_doClick_1, sender !is null ? sender.id_ : null);
- }
-
- public void doDoubleClick (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_doDoubleClick_1, sender !is null ? sender.id_ : null);
- }
-
- public objc.SEL doubleAction ()
- {
- return cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_doubleAction);
- }
-
- public NSImage draggingImageForRowsWithIndexes (NSIndexSet rowIndexes, NSInteger column, NSEvent event, NSPointPointer dragImageOffset)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_draggingImageForRowsWithIndexes_1inColumn_1withEvent_1offset_1,
- rowIndexes !is null ? rowIndexes.id_ : null, column, event !is null ? event.id_ : null, dragImageOffset);
- return result !is null ? new NSImage(result) : null;
- }
-
- public void drawTitleOfColumn (NSInteger column, NSRect aRect)
- {
- OS.objc_msgSend(this.id_, OS.sel_drawTitleOfColumn_1inRect_1, column, aRect);
- }
-
- public NSInteger firstVisibleColumn ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_firstVisibleColumn);
- }
-
- public NSRect frameOfColumn (NSInteger column)
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_frameOfColumn_1, column);
- return result;
- }
-
- public NSRect frameOfInsideOfColumn (NSInteger column)
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_frameOfInsideOfColumn_1, column);
- return result;
- }
-
- public bool hasHorizontalScroller ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_hasHorizontalScroller) !is null;
- }
-
- public bool isLoaded ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isLoaded) !is null;
- }
-
- public bool isTitled ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isTitled) !is null;
- }
-
- public NSInteger lastColumn ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_lastColumn);
- }
-
- public NSInteger lastVisibleColumn ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_lastVisibleColumn);
- }
-
- public void loadColumnZero ()
- {
- OS.objc_msgSend(this.id_, OS.sel_loadColumnZero);
- }
-
- public id loadedCellAtRow (NSInteger row, NSInteger col)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_loadedCellAtRow_1column_1, row, col);
- return result !is null ? new id(result) : null;
- }
-
- public objc.Class matrixClass ()
- {
- return cast(objc.Class) OS.objc_msgSend(this.id_, OS.sel_matrixClass);
- }
-
- public NSMatrix matrixInColumn (NSInteger column)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_matrixInColumn_1, column);
- return result !is null ? new NSMatrix(result) : null;
- }
-
- public NSInteger maxVisibleColumns ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_maxVisibleColumns);
- }
-
- public CGFloat minColumnWidth ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_minColumnWidth);
- }
-
- public NSInteger numberOfVisibleColumns ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfVisibleColumns);
- }
-
- public NSString path ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_path);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString pathSeparator ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_pathSeparator);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString pathToColumn (NSInteger column)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_pathToColumn_1, column);
- return result !is null ? new NSString(result) : null;
- }
-
- public bool prefersAllColumnUserResizing ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_prefersAllColumnUserResizing) !is null;
- }
-
- public void reloadColumn (NSInteger column)
- {
- OS.objc_msgSend(this.id_, OS.sel_reloadColumn_1, column);
- }
-
- public static void removeSavedColumnsWithAutosaveName (NSString name)
- {
- OS.objc_msgSend(OS.class_NSBrowser, OS.sel_removeSavedColumnsWithAutosaveName_1, name !is null ? name.id_ : null);
- }
-
- public bool reusesColumns ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_reusesColumns) !is null;
- }
-
- public void scrollColumnToVisible (NSInteger column)
- {
- OS.objc_msgSend(this.id_, OS.sel_scrollColumnToVisible_1, column);
- }
-
- public void scrollColumnsLeftBy (NSInteger shiftAmount)
- {
- OS.objc_msgSend(this.id_, OS.sel_scrollColumnsLeftBy_1, shiftAmount);
- }
-
- public void scrollColumnsRightBy (NSInteger shiftAmount)
- {
- OS.objc_msgSend(this.id_, OS.sel_scrollColumnsRightBy_1, shiftAmount);
- }
-
- public void scrollViaScroller (NSScroller sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_scrollViaScroller_1, sender !is null ? sender.id_ : null);
- }
-
- public void selectAll (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_selectAll_1, sender !is null ? sender.id_ : null);
- }
-
- public void selectRow (NSInteger row, NSInteger column)
- {
- OS.objc_msgSend(this.id_, OS.sel_selectRow_1inColumn_1, row, column);
- }
-
- public void selectRowIndexes (NSIndexSet indexes, NSInteger column)
- {
- OS.objc_msgSend(this.id_, OS.sel_selectRowIndexes_1inColumn_1, indexes !is null ? indexes.id_ : null, column);
- }
-
- public id selectedCell ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedCell);
- return result !is null ? new id(result) : null;
- }
-
- public id selectedCellInColumn (NSInteger column)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedCellInColumn_1, column);
- return result !is null ? new id(result) : null;
- }
-
- public NSArray selectedCells ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedCells);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSInteger selectedColumn ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_selectedColumn);
- }
-
- public NSInteger selectedRowInColumn (NSInteger column)
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_selectedRowInColumn_1, column);
- }
-
- public NSIndexSet selectedRowIndexesInColumn (NSInteger column)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedRowIndexesInColumn_1, column);
- return result !is null ? new NSIndexSet(result) : null;
- }
-
- public bool sendAction ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_sendAction) !is null;
- }
-
- public bool sendsActionOnArrowKeys ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_sendsActionOnArrowKeys) !is null;
- }
-
- public bool separatesColumns ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_separatesColumns) !is null;
- }
-
- public void setAcceptsArrowKeys (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAcceptsArrowKeys_1, flag);
- }
-
- public void setAllowsBranchSelection (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAllowsBranchSelection_1, flag);
- }
-
- public void setAllowsEmptySelection (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAllowsEmptySelection_1, flag);
- }
-
- public void setAllowsMultipleSelection (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAllowsMultipleSelection_1, flag);
- }
-
- public void setAllowsTypeSelect (bool value)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAllowsTypeSelect_1, value);
- }
-
- public void setBackgroundColor (NSColor color)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBackgroundColor_1, color !is null ? color.id_ : null);
- }
-
- //public void setCellClass(Class factoryId) {
- // OS.objc_msgSend(this.id_, OS.sel_setCellClass_1, factoryId);
- //}
-
- public void setCellPrototype (NSCell aCell)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCellPrototype_1, aCell !is null ? aCell.id_ : null);
- }
-
- public void setColumnResizingType (objc.id columnResizingType)
- {
- OS.objc_msgSend(this.id_, OS.sel_setColumnResizingType_1, columnResizingType);
- }
-
- public void setColumnsAutosaveName (NSString name)
- {
- OS.objc_msgSend(this.id_, OS.sel_setColumnsAutosaveName_1, name !is null ? name.id_ : null);
- }
-
- public void setDelegate (id anObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, anObject !is null ? anObject.id_ : null);
- }
-
- public void setDoubleAction (objc.SEL aSelector)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDoubleAction_1, aSelector);
- }
-
- public void setDraggingSourceOperationMask (objc.id mask, bool isLocal)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDraggingSourceOperationMask_1forLocal_1, mask, isLocal);
- }
-
- public void setHasHorizontalScroller (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setHasHorizontalScroller_1, flag);
- }
-
- public void setLastColumn (NSInteger column)
- {
- OS.objc_msgSend(this.id_, OS.sel_setLastColumn_1, column);
- }
-
- public void setMatrixClass (objc.Class factoryId)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMatrixClass_1, factoryId);
- }
-
- public void setMaxVisibleColumns (NSInteger columnCount)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMaxVisibleColumns_1, columnCount);
- }
-
- public void setMinColumnWidth (CGFloat columnWidth)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMinColumnWidth_1, columnWidth);
- }
-
- public bool setPath (NSString path)
- {
- return OS.objc_msgSend(this.id_, OS.sel_setPath_1, path !is null ? path.id_ : null) !is null;
- }
-
- public void setPathSeparator (NSString newString)
- {
- OS.objc_msgSend(this.id_, OS.sel_setPathSeparator_1, newString !is null ? newString.id_ : null);
- }
-
- public void setPrefersAllColumnUserResizing (bool prefersAllColumnResizing)
- {
- OS.objc_msgSend(this.id_, OS.sel_setPrefersAllColumnUserResizing_1, prefersAllColumnResizing);
- }
-
- public void setReusesColumns (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setReusesColumns_1, flag);
- }
-
- public void setSendsActionOnArrowKeys (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setSendsActionOnArrowKeys_1, flag);
- }
-
- public void setSeparatesColumns (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setSeparatesColumns_1, flag);
- }
-
- public void setTakesTitleFromPreviousColumn (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTakesTitleFromPreviousColumn_1, flag);
- }
-
- public void setTitle (NSString aString, NSInteger column)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTitle_1ofColumn_1, aString !is null ? aString.id_ : null, column);
- }
-
- public void setTitled (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTitled_1, flag);
- }
-
- public void setWidth (CGFloat columnWidth, NSInteger columnIndex)
- {
- OS.objc_msgSend(this.id_, OS.sel_setWidth_1ofColumn_1, columnWidth, columnIndex);
- }
-
- public bool takesTitleFromPreviousColumn ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_takesTitleFromPreviousColumn) !is null;
- }
-
- public void tile ()
- {
- OS.objc_msgSend(this.id_, OS.sel_tile);
- }
-
- public NSRect titleFrameOfColumn (NSInteger column)
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_titleFrameOfColumn_1, column);
- return result;
- }
-
- public CGFloat titleHeight ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_titleHeight);
- }
-
- public NSString titleOfColumn (NSInteger column)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_titleOfColumn_1, column);
- return result !is null ? new NSString(result) : null;
- }
-
- public void updateScroller ()
- {
- OS.objc_msgSend(this.id_, OS.sel_updateScroller);
- }
-
- public void validateVisibleColumns ()
- {
- OS.objc_msgSend(this.id_, OS.sel_validateVisibleColumns);
- }
-
- public CGFloat widthOfColumn (NSInteger column)
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_widthOfColumn_1, column);
- }
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSBrowserCell.d
--- a/dwt/internal/cocoa/NSBrowserCell.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSBrowserCell.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,104 +1,47 @@
-/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSBrowserCell;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSCell;
import dwt.internal.cocoa.NSColor;
-import dwt.internal.cocoa.NSImage;
import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
-public class NSBrowserCell : NSCell
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSImage alternateImage ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_alternateImage);
- return result !is null ? new NSImage(result) : null;
- }
+public class NSBrowserCell : NSCell {
+
+public this () {
+ super();
+}
- public static NSImage branchImage ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBrowserCell, OS.sel_branchImage);
- return result !is null ? new NSImage(result) : null;
- }
+public this (objc.id id) {
+ super(id);
+}
- public NSColor highlightColorInView (NSView controlView)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_highlightColorInView_1, controlView !is null ? controlView.id_ : null);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSImage highlightedBranchImage ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBrowserCell, OS.sel_highlightedBranchImage);
- return result !is null ? new NSImage(result) : null;
- }
+public this (cocoa.id id) {
+ super(id);
- public NSImage image ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_image);
- return result !is null ? new NSImage(result) : null;
- }
-
- public bool isLeaf ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isLeaf) !is null;
- }
-
- public bool isLoaded ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isLoaded) !is null;
- }
-
- public void reset ()
- {
- OS.objc_msgSend(this.id_, OS.sel_reset);
- }
+}
- public void set ()
- {
- OS.objc_msgSend(this.id_, OS.sel_set);
- }
-
- public void setAlternateImage (NSImage newAltImage)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAlternateImage_1, newAltImage !is null ? newAltImage.id_ : null);
- }
+public NSColor highlightColorInView (NSView controlView) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_highlightColorInView_, controlView !is null ? controlView.id : null);
+ return result !is null ? new NSColor(result) : null;
+}
- public void setImage (NSImage image)
- {
- OS.objc_msgSend(this.id_, OS.sel_setImage_1, image !is null ? image.id_ : null);
- }
+public void setLeaf (bool flag) {
+ OS.objc_msgSend(this.id, OS.sel_setLeaf_, flag);
+}
- public void setLeaf (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setLeaf_1, flag);
- }
-
- public void setLoaded (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setLoaded_1, flag);
- }
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSBundle.d
--- a/dwt/internal/cocoa/NSBundle.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSBundle.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,15 +1,15 @@
-/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSBundle;
@@ -19,265 +19,52 @@
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
-public class NSBundle : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public static NSArray allBundles ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_allBundles);
- return result !is null ? new NSArray(result) : null;
- }
-
- public static NSArray allFrameworks ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_allFrameworks);
- return result !is null ? new NSArray(result) : null;
- }
+public class NSBundle : NSObject {
- public NSString builtInPlugInsPath ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_builtInPlugInsPath);
- return result !is null ? new NSString(result) : null;
- }
-
- public static NSBundle bundleForClass (objc.Class aClass)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleForClass_1, aClass);
- return result !is null ? new NSBundle(result) : null;
- }
-
- public NSString bundleIdentifier ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_bundleIdentifier);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString bundlePath ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_bundlePath);
- return result !is null ? new NSString(result) : null;
- }
-
- public static NSBundle bundleWithIdentifier (NSString identifier)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleWithIdentifier_1, identifier !is null ? identifier.id_ : null);
- return result !is null ? new NSBundle(result) : null;
- }
-
- public static NSBundle bundleWithPath (NSString path)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleWithPath_1, path !is null ? path.id_ : null);
- return result !is null ? new NSBundle(result) : null;
- }
+public this() {
+ super();
+}
- public objc.Class classNamed (NSString className)
- {
- return cast(objc.Class) OS.objc_msgSend(this.id_, OS.sel_classNamed_1, className !is null ? className.id_ : null);
- }
-
- public NSString developmentLocalization ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_developmentLocalization);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSArray executableArchitectures ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_executableArchitectures);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSString executablePath ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_executablePath);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSDictionary infoDictionary ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_infoDictionary);
- return result !is null ? new NSDictionary(result) : null;
- }
+public this(objc.id id) {
+ super(id);
+}
- public NSBundle initWithPath (NSString path)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithPath_1, path !is null ? path.id_ : null);
- return result !is null ? this : null;
- }
-
- public bool isLoaded ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isLoaded) !is null;
- }
-
- //public bool load() {
- // return OS.objc_msgSend(this.id_, OS.sel_load) !is null;
- //}
+public this(cocoa.id id) {
+ super(id);
+}
- public bool loadAndReturnError (objc.id** error)
- {
- return OS.objc_msgSend(this.id_, OS.sel_loadAndReturnError_1, error) !is null;
- }
-
- public NSArray localizations ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_localizations);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSDictionary localizedInfoDictionary ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_localizedInfoDictionary);
- return result !is null ? new NSDictionary(result) : null;
- }
-
- public NSString localizedStringForKey (NSString key, NSString value, NSString tableName)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_localizedStringForKey_1value_1table_1, key !is null ? key.id_ : null,
- value !is null ? value.id_ : null, tableName !is null ? tableName.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
+public static bool loadNibFile(NSString fileName, NSDictionary context, NSZone* zone) {
+ return OS.objc_msgSend_bool(OS.class_NSBundle, OS.sel_loadNibFile_externalNameTable_withZone_, fileName !is null ? fileName.id : null,
+ context !is null ? context.id : null, zone);
+}
- public static NSBundle mainBundle ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_mainBundle);
- return result !is null ? new NSBundle(result) : null;
- }
-
- public id objectForInfoDictionaryKey (NSString key)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectForInfoDictionaryKey_1, key !is null ? key.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public NSString pathForAuxiliaryExecutable (NSString executableName)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_pathForAuxiliaryExecutable_1, executableName !is null ? executableName.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString pathForResource_ofType_ (NSString name, NSString ext)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_pathForResource_1ofType_1, name !is null ? name.id_ : null, ext !is null ? ext.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
+public NSString bundleIdentifier() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_bundleIdentifier);
+ return result !is null ? new NSString(result) : null;
+}
- public NSString pathForResource_ofType_inDirectory_ (NSString name, NSString ext, NSString subpath)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_pathForResource_1ofType_1inDirectory_1, name !is null ? name.id_ : null,
- ext !is null ? ext.id_ : null, subpath !is null ? subpath.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public static NSString static_pathForResource_ofType_inDirectory_ (NSString name, NSString ext, NSString bundlePath)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_pathForResource_1ofType_1inDirectory_1, name !is null ? name.id_ : null,
- ext !is null ? ext.id_ : null, bundlePath !is null ? bundlePath.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString pathForResource_ofType_inDirectory_forLocalization_ (NSString name, NSString ext, NSString subpath, NSString localizationName)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_pathForResource_1ofType_1inDirectory_1forLocalization_1, name !is null ? name.id_ : null,
- ext !is null ? ext.id_ : null, subpath !is null ? subpath.id_ : null, localizationName !is null ? localizationName.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public static NSArray static_pathsForResourcesOfType_inDirectory_ (NSString ext, NSString bundlePath)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_pathsForResourcesOfType_1inDirectory_1, ext !is null ? ext.id_ : null,
- bundlePath !is null ? bundlePath.id_ : null);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray pathsForResourcesOfType_inDirectory_ (NSString ext, NSString subpath)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_pathsForResourcesOfType_1inDirectory_1, ext !is null ? ext.id_ : null,
- subpath !is null ? subpath.id_ : null);
- return result !is null ? new NSArray(result) : null;
- }
+public NSString bundlePath() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_bundlePath);
+ return result !is null ? new NSString(result) : null;
+}
- public NSArray pathsForResourcesOfType_inDirectory_forLocalization_ (NSString ext, NSString subpath, NSString localizationName)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_pathsForResourcesOfType_1inDirectory_1forLocalization_1, ext !is null ? ext.id_ : null,
- subpath !is null ? subpath.id_ : null, localizationName !is null ? localizationName.id_ : null);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray preferredLocalizations ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_preferredLocalizations);
- return result !is null ? new NSArray(result) : null;
- }
-
- public static NSArray static_preferredLocalizationsFromArray_ (NSArray localizationsArray)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_preferredLocalizationsFromArray_1,
- localizationsArray !is null ? localizationsArray.id_ : null);
- return result !is null ? new NSArray(result) : null;
- }
-
- public static NSArray static_preferredLocalizationsFromArray_forPreferences_ (NSArray localizationsArray, NSArray preferencesArray)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_preferredLocalizationsFromArray_1forPreferences_1,
- localizationsArray !is null ? localizationsArray.id_ : null, preferencesArray !is null ? preferencesArray.id_ : null);
- return result !is null ? new NSArray(result) : null;
- }
-
- public bool preflightAndReturnError (objc.id** error)
- {
- return OS.objc_msgSend(this.id_, OS.sel_preflightAndReturnError_1, error) !is null;
- }
+public static NSBundle bundleWithPath(NSString path) {
+ objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleWithPath_, path !is null ? path.id : null);
+ return result !is null ? new NSBundle(result) : null;
+}
- public objc.Class principalClass ()
- {
- return cast(objc.Class) OS.objc_msgSend(this.id_, OS.sel_principalClass);
- }
-
- public NSString privateFrameworksPath ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_privateFrameworksPath);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString resourcePath ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_resourcePath);
- return result !is null ? new NSString(result) : null;
- }
+public NSDictionary infoDictionary() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_infoDictionary);
+ return result !is null ? new NSDictionary(result) : null;
+}
- public NSString sharedFrameworksPath ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_sharedFrameworksPath);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString sharedSupportPath ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_sharedSupportPath);
- return result !is null ? new NSString(result) : null;
- }
-
- public bool unload ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_unload) !is null;
- }
-
- public static bool loadNibFile (id fileName, id dict, id zone)
- {
- return OS.objc_msgSend(OS.class_NSBundle, OS.sel_loadNibFile_1externalNameTable_1withZone_1, fileName.id_, dict.id_, 0) !is null;
- }
+public cocoa.id objectForInfoDictionaryKey(NSString key) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForInfoDictionaryKey_, key !is null ? key.id : null);
+ return result !is null ? new cocoa.id(result) : null;
}
+
+}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSButton.d
--- a/dwt/internal/cocoa/NSButton.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSButton.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,20 +1,21 @@
-/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSButton;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSAttributedString;
-import dwt.internal.cocoa.NSButtonCell : NSBezelStyle, NSButtonType;
+import dwt.internal.cocoa.NSButtonCell;
import dwt.internal.cocoa.NSCell;
import dwt.internal.cocoa.NSControl;
import dwt.internal.cocoa.NSEvent;
@@ -25,220 +26,66 @@
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
-public class NSButton : NSControl
-{
-
- public this ()
- {
- super();
- }
+public class NSButton : NSControl {
- public this (objc.id id)
- {
- super(id);
- }
-
- public bool allowsMixedState ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_allowsMixedState) !is null;
- }
-
- public NSImage alternateImage ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_alternateImage);
- return result !is null ? new NSImage(result) : null;
- }
+public this() {
+ super();
+}
- public NSString alternateTitle ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_alternateTitle);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSAttributedString attributedAlternateTitle ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedAlternateTitle);
- return result !is null ? new NSAttributedString(result) : null;
- }
+public this(objc.id id) {
+ super(id);
+}
- public NSAttributedString attributedTitle ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedTitle);
- return result !is null ? new NSAttributedString(result) : null;
- }
-
- public objc.id bezelStyle ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_bezelStyle);
- }
-
- public void getPeriodicDelay (float* delay, float* interval)
- {
- OS.objc_msgSend(this.id_, OS.sel_getPeriodicDelay_1interval_1, delay, interval);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public void highlight (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_highlight_1, flag);
- }
-
- public NSImage image ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_image);
- return result !is null ? new NSImage(result) : null;
- }
+public void setAllowsMixedState(bool flag) {
+ OS.objc_msgSend(this.id, OS.sel_setAllowsMixedState_, flag);
+}
- public objc.id imagePosition ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_imagePosition);
- }
-
- public bool isBordered ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isBordered) !is null;
- }
-
- public bool isTransparent ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isTransparent) !is null;
- }
+public void setAttributedTitle(NSAttributedString aString) {
+ OS.objc_msgSend(this.id, OS.sel_setAttributedTitle_, aString !is null ? aString.id : null);
+}
- public NSString keyEquivalent ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_keyEquivalent);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSUInteger keyEquivalentModifierMask ()
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_keyEquivalentModifierMask);
- }
+public void setBezelStyle(NSBezelStyle bezelStyle) {
+ OS.objc_msgSend(this.id, OS.sel_setBezelStyle_, bezelStyle);
+}
- public bool performKeyEquivalent (NSEvent key)
- {
- return OS.objc_msgSend(this.id_, OS.sel_performKeyEquivalent_1, key !is null ? key.id_ : null) !is null;
- }
-
- public void setAllowsMixedState (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAllowsMixedState_1, flag);
- }
-
- public void setAlternateImage (NSImage image)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAlternateImage_1, image !is null ? image.id_ : null);
- }
+public void setBordered(bool flag) {
+ OS.objc_msgSend(this.id, OS.sel_setBordered_, flag);
+}
- public void setAlternateTitle (NSString aString)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAlternateTitle_1, aString !is null ? aString.id_ : null);
- }
-
- public void setAttributedAlternateTitle (NSAttributedString obj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAttributedAlternateTitle_1, obj !is null ? obj.id_ : null);
- }
+public void setButtonType(NSButtonType aType) {
+ OS.objc_msgSend(this.id, OS.sel_setButtonType_, aType);
+}
- public void setAttributedTitle (NSAttributedString aString)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAttributedTitle_1, aString !is null ? aString.id_ : null);
- }
-
- public void setBezelStyle (NSBezelStyle bezelStyle)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBezelStyle_1, bezelStyle);
- }
-
- public void setBordered (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBordered_1, flag);
- }
+public void setImage(NSImage image) {
+ OS.objc_msgSend(this.id, OS.sel_setImage_, image !is null ? image.id : null);
+}
- public void setButtonType (NSButtonType aType)
- {
- OS.objc_msgSend(this.id_, OS.sel_setButtonType_1, aType);
- }
-
- public void setImage (NSImage image)
- {
- OS.objc_msgSend(this.id_, OS.sel_setImage_1, image !is null ? image.id_ : null);
- }
-
- public void setImagePosition (NSCellImagePosition aPosition)
- {
- OS.objc_msgSend(this.id_, OS.sel_setImagePosition_1, aPosition);
- }
+public void setImagePosition(NSCellImagePosition aPosition) {
+ OS.objc_msgSend(this.id, OS.sel_setImagePosition_, aPosition);
+}
- public void setKeyEquivalent (NSString charCode)
- {
- OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalent_1, charCode !is null ? charCode.id_ : null);
- }
-
- public void setKeyEquivalentModifierMask (NSUInteger mask)
- {
- OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalentModifierMask_1, mask);
- }
-
- public void setNextState ()
- {
- OS.objc_msgSend(this.id_, OS.sel_setNextState);
- }
+public void setState(NSInteger value) {
+ OS.objc_msgSend(this.id, OS.sel_setState_, value);
+}
- public void setPeriodicDelay (float delay, float interval)
- {
- OS.objc_msgSend(this.id_, OS.sel_setPeriodicDelay_1interval_1, delay, interval);
- }
-
- public void setShowsBorderOnlyWhileMouseInside (bool show)
- {
- OS.objc_msgSend(this.id_, OS.sel_setShowsBorderOnlyWhileMouseInside_1, show);
- }
+public void setTitle(NSString aString) {
+ OS.objc_msgSend(this.id, OS.sel_setTitle_, aString !is null ? aString.id : null);
+}
- public void setSound (NSSound aSound)
- {
- OS.objc_msgSend(this.id_, OS.sel_setSound_1, aSound !is null ? aSound.id_ : null);
- }
-
- public void setState (NSInteger value)
- {
- OS.objc_msgSend(this.id_, OS.sel_setState_1, value);
- }
-
- public void setTitle (NSString aString)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTitle_1, aString !is null ? aString.id_ : null);
- }
+public NSInteger state() {
+ return OS.objc_msgSend(this.id, OS.sel_state);
+}
- public void setTitleWithMnemonic (NSString StringWithAmpersand)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTitleWithMnemonic_1, StringWithAmpersand !is null ? StringWithAmpersand.id_ : null);
- }
-
- public void setTransparent (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTransparent_1, flag);
- }
-
- public bool showsBorderOnlyWhileMouseInside ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_showsBorderOnlyWhileMouseInside) !is null;
- }
+public static objc.Class cellClass() {
+ return cast(objc.Class) OS.objc_msgSend(OS.class_NSButton, OS.sel_cellClass);
+}
- public NSSound sound ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_sound);
- return result !is null ? new NSSound(result) : null;
- }
-
- public NSInteger state ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_state);
- }
-
- public NSString title ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_title);
- return result !is null ? new NSString(result) : null;
- }
+public static void setCellClass(objc.Class factoryId) {
+ OS.objc_msgSend(OS.class_NSButton, OS.sel_setCellClass_, factoryId);
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSButtonCell.d
--- a/dwt/internal/cocoa/NSButtonCell.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSButtonCell.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,69 +1,45 @@
-/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSButtonCell;
-import dwt.internal.cocoa.CGFloat;
-import dwt.internal.cocoa.id;
+import dwt.internal.c.Carbon;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSActionCell;
-import dwt.internal.cocoa.NSAttributedString;
import dwt.internal.cocoa.NSColor;
-import dwt.internal.cocoa.NSEvent;
-import dwt.internal.cocoa.NSFont;
-import dwt.internal.cocoa.NSImage;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSRect;
-import dwt.internal.cocoa.NSSound;
import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
-enum NSBezelStyle : NSUInteger
-{
- NSRoundedBezelStyle = 1,
- NSRegularSquareBezelStyle = 2,
- NSThickSquareBezelStyle = 3,
- NSThickerSquareBezelStyle = 4,
- NSDisclosureBezelStyle = 5,
- NSShadowlessSquareBezelStyle = 6,
- NSCircularBezelStyle = 7,
- NSTexturedSquareBezelStyle = 8,
- NSHelpButtonBezelStyle = 9,
- NSSmallSquareBezelStyle = 10,
- NSTexturedRoundedBezelStyle = 11,
- NSRoundRectBezelStyle = 12,
- NSRecessedBezelStyle = 13,
+enum NSBezelStyle : NSUInteger {
+ NSRoundedBezelStyle = 1,
+ NSRegularSquareBezelStyle = 2,
+ NSThickSquareBezelStyle = 3,
+ NSThickerSquareBezelStyle = 4,
+ NSDisclosureBezelStyle = 5,
+ NSShadowlessSquareBezelStyle = 6,
+ NSCircularBezelStyle = 7,
+ NSTexturedSquareBezelStyle = 8,
+ NSHelpButtonBezelStyle = 9,
+ NSSmallSquareBezelStyle = 10,
+ NSTexturedRoundedBezelStyle = 11,
+ NSRoundRectBezelStyle = 12,
+ NSRecessedBezelStyle = 13,
NSRoundedDisclosureBezelStyle = 14,
}
-alias NSBezelStyle.NSRoundedBezelStyle NSRoundedBezelStyle;
-alias NSBezelStyle.NSRegularSquareBezelStyle NSRegularSquareBezelStyle;
-alias NSBezelStyle.NSThickSquareBezelStyle NSThickSquareBezelStyle;
-alias NSBezelStyle.NSThickerSquareBezelStyle NSThickerSquareBezelStyle;
-alias NSBezelStyle.NSDisclosureBezelStyle NSDisclosureBezelStyle;
-alias NSBezelStyle.NSShadowlessSquareBezelStyle NSShadowlessSquareBezelStyle;
-alias NSBezelStyle.NSCircularBezelStyle NSCircularBezelStyle;
-alias NSBezelStyle.NSTexturedSquareBezelStyle NSTexturedSquareBezelStyle;
-alias NSBezelStyle.NSHelpButtonBezelStyle NSHelpButtonBezelStyle;
-alias NSBezelStyle.NSSmallSquareBezelStyle NSSmallSquareBezelStyle;
-alias NSBezelStyle.NSTexturedRoundedBezelStyle NSTexturedRoundedBezelStyle;
-alias NSBezelStyle.NSRoundRectBezelStyle NSRoundRectBezelStyle;
-alias NSBezelStyle.NSRecessedBezelStyle NSRecessedBezelStyle;
-alias NSBezelStyle.NSRoundedDisclosureBezelStyle NSRoundedDisclosureBezelStyle;
-
-enum NSButtonType : NSUInteger
-{
+enum NSButtonType : NSUInteger {
NSMomentaryLightButton = 0,
NSPushOnPushOffButton = 1,
NSToggleButton = 2,
@@ -76,317 +52,35 @@
NSMomentaryLight = 7
}
-alias NSButtonType.NSMomentaryLightButton NSMomentaryLightButton;
-alias NSButtonType.NSPushOnPushOffButton NSPushOnPushOffButton;
-alias NSButtonType.NSToggleButton NSToggleButton;
-alias NSButtonType.NSSwitchButton NSSwitchButton;
-alias NSButtonType.NSRadioButton NSRadioButton;
-alias NSButtonType.NSMomentaryChangeButton NSMomentaryChangeButton;
-alias NSButtonType.NSOnOffButton NSOnOffButton;
-alias NSButtonType.NSMomentaryPushInButton NSMomentaryPushInButton;
-alias NSButtonType.NSMomentaryPushButton NSMomentaryPushButton;
-alias NSButtonType.NSMomentaryLight NSMomentaryLight;
-
-public class NSButtonCell : NSActionCell
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSImage alternateImage ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_alternateImage);
- return result !is null ? new NSImage(result) : null;
- }
-
- public NSString alternateMnemonic ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_alternateMnemonic);
- return result !is null ? new NSString(result) : null;
- }
+public class NSButtonCell : NSActionCell {
- public NSUInteger alternateMnemonicLocation ()
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_alternateMnemonicLocation);
- }
-
- public NSString alternateTitle ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_alternateTitle);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSAttributedString attributedAlternateTitle ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedAlternateTitle);
- return result !is null ? new NSAttributedString(result) : null;
- }
-
- public NSAttributedString attributedTitle ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedTitle);
- return result !is null ? new NSAttributedString(result) : null;
- }
-
- public NSColor backgroundColor ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_backgroundColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public objc.id bezelStyle ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_bezelStyle);
- }
-
- public void drawBezelWithFrame (NSRect frame, NSView controlView)
- {
- OS.objc_msgSend(this.id_, OS.sel_drawBezelWithFrame_1inView_1, frame, controlView !is null ? controlView.id_ : null);
- }
+public this() {
+ super();
+}
- public void drawImage (NSImage image, NSRect frame, NSView controlView)
- {
- OS.objc_msgSend(this.id_, OS.sel_drawImage_1withFrame_1inView_1, image !is null ? image.id_ : null, frame,
- controlView !is null ? controlView.id_ : null);
- }
-
- public NSRect drawTitle (NSAttributedString title, NSRect frame, NSView controlView)
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_drawTitle_1withFrame_1inView_1, title !is null ? title.id_ : null, frame,
- controlView !is null ? controlView.id_ : null);
- return result;
- }
-
- public void getPeriodicDelay (float* delay, float* interval)
- {
- OS.objc_msgSend(this.id_, OS.sel_getPeriodicDelay_1interval_1, delay, interval);
- }
-
- public objc.id gradientType ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_gradientType);
- }
-
- public NSInteger highlightsBy ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_highlightsBy);
- }
-
- public bool imageDimsWhenDisabled ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_imageDimsWhenDisabled) !is null;
- }
-
- public objc.id imagePosition ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_imagePosition);
- }
+public this(objc.id id) {
+ super(id);
+}
- public objc.id imageScaling ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_imageScaling);
- }
-
- public bool isOpaque ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isOpaque) !is null;
- }
-
- public bool isTransparent ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isTransparent) !is null;
- }
-
- public NSString keyEquivalent ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_keyEquivalent);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSFont keyEquivalentFont ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_keyEquivalentFont);
- return result !is null ? new NSFont(result) : null;
- }
-
- public NSUInteger keyEquivalentModifierMask ()
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_keyEquivalentModifierMask);
- }
-
- public void mouseEntered (NSEvent event)
- {
- OS.objc_msgSend(this.id_, OS.sel_mouseEntered_1, event !is null ? event.id_ : null);
- }
-
- public void mouseExited (NSEvent event)
- {
- OS.objc_msgSend(this.id_, OS.sel_mouseExited_1, event !is null ? event.id_ : null);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public void performClick (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_performClick_1, sender !is null ? sender.id_ : null);
- }
-
- public void setAlternateImage (NSImage image)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAlternateImage_1, image !is null ? image.id_ : null);
- }
-
- public void setAlternateMnemonicLocation (NSUInteger location)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAlternateMnemonicLocation_1, location);
- }
-
- public void setAlternateTitle (NSString aString)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAlternateTitle_1, aString !is null ? aString.id_ : null);
- }
-
- public void setAlternateTitleWithMnemonic (NSString StringWithAmpersand)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAlternateTitleWithMnemonic_1, StringWithAmpersand !is null ? StringWithAmpersand.id_ : null);
- }
-
- public void setAttributedAlternateTitle (NSAttributedString obj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAttributedAlternateTitle_1, obj !is null ? obj.id_ : null);
- }
-
- public void setAttributedTitle (NSAttributedString obj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAttributedTitle_1, obj !is null ? obj.id_ : null);
- }
+public void setBackgroundColor(NSColor color) {
+ OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_, color !is null ? color.id : null);
+}
- public void setBackgroundColor (NSColor color)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBackgroundColor_1, color !is null ? color.id_ : null);
- }
-
- public void setBezelStyle (objc.id bezelStyle)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBezelStyle_1, bezelStyle);
- }
-
- public void setButtonType (objc.id aType)
- {
- OS.objc_msgSend(this.id_, OS.sel_setButtonType_1, aType);
- }
-
- public void setFont (NSFont fontObj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFont_1, fontObj !is null ? fontObj.id_ : null);
- }
-
- public void setGradientType (objc.id type)
- {
- OS.objc_msgSend(this.id_, OS.sel_setGradientType_1, type);
- }
-
- public void setHighlightsBy (NSInteger aType)
- {
- OS.objc_msgSend(this.id_, OS.sel_setHighlightsBy_1, aType);
- }
-
- public void setImageDimsWhenDisabled (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setImageDimsWhenDisabled_1, flag);
- }
-
- public void setImagePosition (objc.id aPosition)
- {
- OS.objc_msgSend(this.id_, OS.sel_setImagePosition_1, aPosition);
- }
+public void setButtonType(objc.id aType) {
+ OS.objc_msgSend(this.id, OS.sel_setButtonType_, aType);
+}
- public void setImageScaling (objc.id scaling)
- {
- OS.objc_msgSend(this.id_, OS.sel_setImageScaling_1, scaling);
- }
-
- public void setKeyEquivalent (NSString aKeyEquivalent)
- {
- OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalent_1, aKeyEquivalent !is null ? aKeyEquivalent.id_ : null);
- }
-
- public void setKeyEquivalentFont_ (NSFont fontObj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalentFont_1, fontObj !is null ? fontObj.id_ : null);
- }
-
- public void setKeyEquivalentFont_size_ (NSString fontName, CGFloat fontSize)
- {
- OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalentFont_1size_1, fontName !is null ? fontName.id_ : null, fontSize);
- }
-
- public void setKeyEquivalentModifierMask (NSUInteger mask)
- {
- OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalentModifierMask_1, mask);
- }
-
- public void setPeriodicDelay (float delay, float interval)
- {
- OS.objc_msgSend(this.id_, OS.sel_setPeriodicDelay_1interval_1, delay, interval);
- }
-
- public void setShowsBorderOnlyWhileMouseInside (bool show)
- {
- OS.objc_msgSend(this.id_, OS.sel_setShowsBorderOnlyWhileMouseInside_1, show);
- }
-
- public void setShowsStateBy (NSInteger aType)
- {
- OS.objc_msgSend(this.id_, OS.sel_setShowsStateBy_1, aType);
- }
+public void setImagePosition(objc.id aPosition) {
+ OS.objc_msgSend(this.id, OS.sel_setImagePosition_, aPosition);
+}
- public void setSound (NSSound aSound)
- {
- OS.objc_msgSend(this.id_, OS.sel_setSound_1, aSound !is null ? aSound.id_ : null);
- }
-
- public void setTitle (NSString aString)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTitle_1, aString !is null ? aString.id_ : null);
- }
-
- public void setTitleWithMnemonic (NSString StringWithAmpersand)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTitleWithMnemonic_1, StringWithAmpersand !is null ? StringWithAmpersand.id_ : null);
- }
-
- public void setTransparent (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTransparent_1, flag);
- }
-
- public bool showsBorderOnlyWhileMouseInside ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_showsBorderOnlyWhileMouseInside) !is null;
- }
-
- public NSInteger showsStateBy ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_showsStateBy);
- }
-
- public NSSound sound ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_sound);
- return result !is null ? new NSSound(result) : null;
- }
-
- public NSString title ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_title);
- return result !is null ? new NSString(result) : null;
- }
+public NSString title() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+ return result !is null ? new NSString(result) : null;
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCIImageRep.d
--- a/dwt/internal/cocoa/NSCIImageRep.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSCIImageRep;
-
-import dwt.internal.cocoa.CIImage;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSImageRep;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSCIImageRep : NSImageRep
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public CIImage CIImagee ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_CIImage);
- return result !is null ? new CIImage(result) : null;
- }
-
- public static id imageRepWithCIImage (CIImage image)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCIImageRep, OS.sel_imageRepWithCIImage_1, image !is null ? image.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public NSCIImageRep initWithCIImage (CIImage image)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithCIImage_1, image !is null ? image.id_ : null);
- return result !is null ? this : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCachedImageRep.d
--- a/dwt/internal/cocoa/NSCachedImageRep.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSCachedImageRep;
-
-import dwt.internal.cocoa.NSImageRep;
-import dwt.internal.cocoa.NSRect;
-import dwt.internal.cocoa.NSSize;
-import dwt.internal.cocoa.NSWindow;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSCachedImageRep : NSImageRep
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSCachedImageRep initWithSize (NSSize size, objc.id depth, bool flag, bool alpha)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithSize_1depth_1separate_1alpha_1, size, depth, flag, alpha);
- return result !is null ? this : null;
- }
-
- public NSCachedImageRep initWithWindow (NSWindow win, NSRect rect)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithWindow_1rect_1, win !is null ? win.id_ : null, rect);
- return result !is null ? this : null;
- }
-
- public NSRect rect ()
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_rect);
- return result;
- }
-
- public NSWindow window ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_window);
- return result !is null ? new NSWindow(result) : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCachedURLResponse.d
--- a/dwt/internal/cocoa/NSCachedURLResponse.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSCachedURLResponse;
-
-import dwt.internal.cocoa.NSData;
-import dwt.internal.cocoa.NSDictionary;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSURLResponse;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSCachedURLResponse : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSData data ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_data);
- return result !is null ? new NSData(result) : null;
- }
-
- public NSCachedURLResponse initWithResponse_data_ (NSURLResponse response, NSData data)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithResponse_1data_1, response !is null ? response.id_ : null,
- data !is null ? data.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSCachedURLResponse initWithResponse_data_userInfo_storagePolicy_ (NSURLResponse response, NSData data, NSDictionary userInfo,
- objc.id storagePolicy)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithResponse_1data_1userInfo_1storagePolicy_1, response !is null ? response.id_ : null,
- data !is null ? data.id_ : null, userInfo !is null ? userInfo.id_ : null, storagePolicy);
- return result !is null ? this : null;
- }
-
- public NSURLResponse response ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_response);
- return result !is null ? new NSURLResponse(result) : null;
- }
-
- public objc.id storagePolicy ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_storagePolicy);
- }
-
- public NSDictionary userInfo ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_userInfo);
- return result !is null ? new NSDictionary(result) : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCalendar.d
--- a/dwt/internal/cocoa/NSCalendar.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSCalendar;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSDate;
-import dwt.internal.cocoa.NSDateComponents;
-import dwt.internal.cocoa.NSLocale;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSRange;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.NSTimeZone;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSCalendar : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public static id autoupdatingCurrentCalendar ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCalendar, OS.sel_autoupdatingCurrentCalendar);
- return result !is null ? new id(result) : null;
- }
-
- public NSString calendarIdentifier ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_calendarIdentifier);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSDateComponents components_fromDate_ (NSUInteger unitFlags, NSDate date)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_components_1fromDate_1, unitFlags, date !is null ? date.id_ : null);
- return result !is null ? new NSDateComponents(result) : null;
- }
-
- public NSDateComponents components_fromDate_toDate_options_ (NSUInteger unitFlags, NSDate startingDate, NSDate resultDate, NSUInteger opts)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_components_1fromDate_1toDate_1options_1, unitFlags,
- startingDate !is null ? startingDate.id_ : null, resultDate !is null ? resultDate.id_ : null, opts);
- return result !is null ? new NSDateComponents(result) : null;
- }
-
- public static id currentCalendar ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCalendar, OS.sel_currentCalendar);
- return result !is null ? new id(result) : null;
- }
-
- public NSDate dateByAddingComponents (NSDateComponents comps, NSDate date, NSUInteger opts)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_dateByAddingComponents_1toDate_1options_1, comps !is null ? comps.id_ : null,
- date !is null ? date.id_ : null, opts);
- return result !is null ? new NSDate(result) : null;
- }
-
- public NSDate dateFromComponents (NSDateComponents comps)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_dateFromComponents_1, comps !is null ? comps.id_ : null);
- return result !is null ? new NSDate(result) : null;
- }
-
- public NSUInteger firstWeekday ()
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_firstWeekday);
- }
-
- public NSCalendar initWithCalendarIdentifier (NSString ident)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithCalendarIdentifier_1, ident !is null ? ident.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSLocale locale ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_locale);
- return result !is null ? new NSLocale(result) : null;
- }
-
- public NSRange maximumRangeOfUnit (objc.id unit)
- {
- NSRange result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_maximumRangeOfUnit_1, unit);
- return result;
- }
-
- public NSUInteger minimumDaysInFirstWeek ()
- {
- return cast(NSUInteger)OS.objc_msgSend(this.id_, OS.sel_minimumDaysInFirstWeek);
- }
-
- public NSRange minimumRangeOfUnit (objc.id unit)
- {
- NSRange result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_minimumRangeOfUnit_1, unit);
- return result;
- }
-
- public NSUInteger ordinalityOfUnit (objc.id smaller, objc.id larger, NSDate date)
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_ordinalityOfUnit_1inUnit_1forDate_1, smaller, larger, date !is null ? date.id_ : null);
- }
-
- public NSRange rangeOfUnit_inUnit_forDate_ (objc.id smaller, objc.id larger, NSDate date)
- {
- NSRange result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_rangeOfUnit_1inUnit_1forDate_1, smaller, larger, date !is null ? date.id_ : null);
- return result;
- }
-
- public bool rangeOfUnit_startDate_interval_forDate_ (objc.id unit, objc.id datep, objc.id tip, NSDate date)
- {
- return OS.objc_msgSend(this.id_, OS.sel_rangeOfUnit_1startDate_1interval_1forDate_1, unit, datep, tip, date !is null ? date.id_ : null) !is null;
- }
-
- public void setFirstWeekday (NSUInteger weekday)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFirstWeekday_1, weekday);
- }
-
- public void setLocale (NSLocale locale)
- {
- OS.objc_msgSend(this.id_, OS.sel_setLocale_1, locale !is null ? locale.id_ : null);
- }
-
- public void setMinimumDaysInFirstWeek (NSUInteger mdw)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMinimumDaysInFirstWeek_1, mdw);
- }
-
- public void setTimeZone (NSTimeZone tz)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTimeZone_1, tz !is null ? tz.id_ : null);
- }
-
- public NSTimeZone timeZone ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_timeZone);
- return result !is null ? new NSTimeZone(result) : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCalendarDate.d
--- a/dwt/internal/cocoa/NSCalendarDate.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSCalendarDate.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,196 +1,87 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSCalendarDate;
-import dwt.internal.cocoa.id;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSDate;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSTimeZone;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
-public class NSCalendarDate : NSDate
-{
-
- public this ()
- {
- super();
- }
+public class NSCalendarDate : NSDate {
- public this (objc.id id)
- {
- super(id);
- }
-
- public static NSCalendarDate calendarDate ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_calendarDate);
- return result !is null ? new NSCalendarDate(result) : null;
- }
+public this() {
+ super();
+}
- public NSString calendarFormat ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_calendarFormat);
- return result !is null ? new NSString(result) : null;
- }
+public this(objc.id id) {
+ super(id);
+}
- public NSCalendarDate dateByAddingYears (NSInteger year, NSInteger month, NSInteger day, NSInteger hour, NSInteger minute, NSInteger second)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_dateByAddingYears_1months_1days_1hours_1minutes_1seconds_1, year, month, day, hour, minute,
- second);
- return result is this.id_ ? this : (result !is null ? new NSCalendarDate(result) : null);
- }
-
- public static id static_dateWithString_calendarFormat_ (NSString description, NSString format)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithString_1calendarFormat_1,
- description !is null ? description.id_ : null, format !is null ? format.id_ : null);
- return result !is null ? new id(result) : null;
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public static id static_dateWithString_calendarFormat_locale_ (NSString description, NSString format, id locale)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithString_1calendarFormat_1locale_1,
- description !is null ? description.id_ : null, format !is null ? format.id_ : null, locale !is null ? locale.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static NSCalendarDate dateWithYear (NSInteger year, NSInteger month, NSInteger day, NSInteger hour, NSInteger minute, NSInteger second, NSTimeZone aTimeZone)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithYear_1month_1day_1hour_1minute_1second_1timeZone_1, year, month,
- day, hour, minute, second, aTimeZone !is null ? aTimeZone.id_ : null);
- return result !is null ? new NSCalendarDate(result) : null;
- }
-
- public NSInteger dayOfCommonEra ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_dayOfCommonEra);
- }
+public static NSCalendarDate calendarDate() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_calendarDate);
+ return result !is null ? new NSCalendarDate(result) : null;
+}
- public NSInteger dayOfMonth ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_dayOfMonth);
- }
-
- public NSInteger dayOfWeek ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_dayOfWeek);
- }
+public static NSCalendarDate dateWithYear(NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) {
+ objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithYear_month_day_hour_minute_second_timeZone_, year, month, day, hour, minute, second, aTimeZone !is null ? aTimeZone.id : null);
+ return result !is null ? new NSCalendarDate(result) : null;
+}
- public NSInteger dayOfYear ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_dayOfYear);
- }
-
- public NSString description ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_description);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString descriptionWithCalendarFormat_ (NSString format)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithCalendarFormat_1, format !is null ? format.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
+public NSInteger dayOfMonth() {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_dayOfMonth);
+}
- public NSString descriptionWithCalendarFormat_locale_ (NSString format, id locale)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithCalendarFormat_1locale_1, format !is null ? format.id_ : null,
- locale !is null ? locale.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
+public NSInteger hourOfDay() {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_hourOfDay);
+}
- public NSString descriptionWithLocale (id locale)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSInteger hourOfDay ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_hourOfDay);
- }
+public NSInteger minuteOfHour() {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_minuteOfHour);
+}
- public NSCalendarDate initWithString_ (NSString description)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1, description !is null ? description.id_ : null);
- return result !is null ? this : null;
- }
+public NSInteger monthOfYear() {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_monthOfYear);
+}
- public NSCalendarDate initWithString_calendarFormat_ (NSString description, NSString format)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1calendarFormat_1, description !is null ? description.id_ : null,
- format !is null ? format.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSCalendarDate initWithString_calendarFormat_locale_ (NSString description, NSString format, id locale)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1calendarFormat_1locale_1, description !is null ? description.id_ : null,
- format !is null ? format.id_ : null, locale !is null ? locale.id_ : null);
- return result !is null ? this : null;
- }
+public NSInteger secondOfMinute() {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_secondOfMinute);
+}
- public id initWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithYear_1month_1day_1hour_1minute_1second_1timeZone_1, year, month, day, hour, minute,
- second, aTimeZone !is null ? aTimeZone.id_ : null);
- return result !is null ? new id(result) : null;
- }
+public NSTimeZone timeZone() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_timeZone);
+ return result !is null ? new NSTimeZone(result) : null;
+}
- public NSInteger minuteOfHour ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_minuteOfHour);
- }
-
- public NSInteger monthOfYear ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_monthOfYear);
- }
-
- public NSInteger secondOfMinute ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_secondOfMinute);
- }
+public int /*long*/yearOfCommonEra() {
+ return OS.objc_msgSend(this.id, OS.sel_yearOfCommonEra);
+}
- public void setCalendarFormat (NSString format)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCalendarFormat_1, format !is null ? format.id_ : null);
- }
-
- public void setTimeZone (NSTimeZone aTimeZone)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTimeZone_1, aTimeZone !is null ? aTimeZone.id_ : null);
- }
+public static NSDate dateWithTimeIntervalSinceNow(double secs) {
+ objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithTimeIntervalSinceNow_, secs);
+ return result !is null ? new NSCalendarDate(result) : null;
+}
- public NSTimeZone timeZone ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_timeZone);
- return result !is null ? new NSTimeZone(result) : null;
- }
-
- public NSInteger yearOfCommonEra ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_yearOfCommonEra);
- }
-
- public void years (NSInteger* yp, NSInteger* mop, NSInteger* dp, NSInteger* hp, NSInteger* mip, NSInteger* sp, NSCalendarDate date)
- {
- OS.objc_msgSend(this.id_, OS.sel_years_1months_1days_1hours_1minutes_1seconds_1sinceDate_1, yp, mop, dp, hp, mip, sp,
- date !is null ? date.id_ : null);
- }
+public static NSDate distantFuture() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_distantFuture);
+ return result !is null ? new NSCalendarDate(result) : null;
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCell.d
--- a/dwt/internal/cocoa/NSCell.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSCell.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,40 +1,33 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSCell;
-import dwt.internal.cocoa.id;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSAttributedString;
-import dwt.internal.cocoa.NSCell;
-import dwt.internal.cocoa.NSColor;
-import dwt.internal.cocoa.NSEvent;
import dwt.internal.cocoa.NSFont;
import dwt.internal.cocoa.NSFormatter;
import dwt.internal.cocoa.NSImage;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSMenu;
import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSPoint;
import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSSize;
import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.NSText;
import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
-/*alias NSUInteger NSControlSize;*/
-
enum NSControlSize : NSUInteger
{
NSRegularControlSize,
@@ -42,847 +35,105 @@
NSMiniControlSize
}
-alias NSControlSize.NSRegularControlSize NSRegularControlSize;
-alias NSControlSize.NSSmallControlSize NSSmallControlSize;
-alias NSControlSize.NSMiniControlSize NSMiniControlSize;
-
-/*alias NSUInteger NSCellAttribute;*/
-
-enum NSCellAttribute : NSUInteger
+enum NSImageScaling : NSUInteger
{
- NSCellDisabled = 0,
- NSCellState = 1,
- NSPushInCell = 2,
- NSCellEditable = 3,
- NSChangeGrayCell = 4,
- NSCellHighlighted = 5,
- NSCellLightsByContents = 6,
- NSCellLightsByGray = 7,
- NSChangeBackgroundCell = 8,
- NSCellLightsByBackground = 9,
- NSCellIsBordered = 10,
- NSCellHasOverlappingImage = 11,
- NSCellHasImageHorizontal = 12,
- NSCellHasImageOnLeftOrBottom = 13,
- NSCellChangesContents = 14,
- NSCellIsInsetButton = 15,
- NSCellAllowsMixedState = 16
+ NSImageScaleProportionallyDown = 0,
+ NSImageScaleAxesIndependently,
+ NSImageScaleNone,
+ NSImageScaleProportionallyUpOrDown
}
-alias NSCellAttribute.NSCellDisabled NSCellDisabled;
-alias NSCellAttribute.NSCellState NSCellState;
-alias NSCellAttribute.NSPushInCell NSPushInCell;
-alias NSCellAttribute.NSCellEditable NSCellEditable;
-alias NSCellAttribute.NSChangeGrayCell NSChangeGrayCell;
-alias NSCellAttribute.NSCellHighlighted NSCellHighlighted;
-alias NSCellAttribute.NSCellLightsByContents NSCellLightsByContents;
-alias NSCellAttribute.NSCellLightsByGray NSCellLightsByGray;
-alias NSCellAttribute.NSChangeBackgroundCell NSChangeBackgroundCell;
-alias NSCellAttribute.NSCellLightsByBackground NSCellLightsByBackground;
-alias NSCellAttribute.NSCellIsBordered NSCellIsBordered;
-alias NSCellAttribute.NSCellHasOverlappingImage NSCellHasOverlappingImage;
-alias NSCellAttribute.NSCellHasImageHorizontal NSCellHasImageHorizontal;
-alias NSCellAttribute.NSCellHasImageOnLeftOrBottom NSCellHasImageOnLeftOrBottom;
-alias NSCellAttribute.NSCellChangesContents NSCellChangesContents;
-alias NSCellAttribute.NSCellIsInsetButton NSCellIsInsetButton;
-alias NSCellAttribute.NSCellAllowsMixedState NSCellAllowsMixedState;
-
-enum NSControlTint : NSUInteger
-{
- NSDefaultControlTint = 0,
- NSBlueControlTint = 1,
- NSGraphiteControlTint = 6,
- NSClearControlTint = 7
-}
-
-alias NSControlTint.NSDefaultControlTint NSDefaultControlTint;
-alias NSControlTint.NSBlueControlTint NSBlueControlTint;
-alias NSControlTint.NSGraphiteControlTint NSGraphiteControlTint;
-alias NSControlTint.NSClearControlTint NSClearControlTint;
-
enum NSCellImagePosition : NSUInteger
{
- NSNoImage = 0,
- NSImageOnly = 1,
- NSImageLeft = 2,
- NSImageRight = 3,
- NSImageBelow = 4,
- NSImageAbove = 5,
+ NSNoImage = 0,
+ NSImageOnly = 1,
+ NSImageLeft = 2,
+ NSImageRight = 3,
+ NSImageBelow = 4,
+ NSImageAbove = 5,
NSImageOverlaps = 6
}
-alias NSCellImagePosition.NSNoImage NSNoImage;
-alias NSCellImagePosition.NSImageOnly NSImageOnly;
-alias NSCellImagePosition.NSImageLeft NSImageLeft;
-alias NSCellImagePosition.NSImageRight NSImageRight;
-alias NSCellImagePosition.NSImageBelow NSImageBelow;
-alias NSCellImagePosition.NSImageAbove NSImageAbove;
-alias NSCellImagePosition.NSImageOverlaps NSImageOverlaps;
-
-public class NSCell : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public bool acceptsFirstResponder ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_acceptsFirstResponder) !is null;
- }
-
- public objc.SEL action ()
- {
- return cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_action);
- }
-
- public objc.id alignment ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_alignment);
- }
-
- public bool allowsEditingTextAttributes ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_allowsEditingTextAttributes) !is null;
- }
+public class NSCell : NSObject {
- public bool allowsMixedState ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_allowsMixedState) !is null;
- }
-
- public bool allowsUndo ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_allowsUndo) !is null;
- }
-
- public NSAttributedString attributedStringValue ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedStringValue);
- return result !is null ? new NSAttributedString(result) : null;
- }
-
- public objc.id backgroundStyle ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_backgroundStyle);
- }
-
- public objc.id baseWritingDirection ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_baseWritingDirection);
- }
-
- public void calcDrawInfo (NSRect aRect)
- {
- OS.objc_msgSend(this.id_, OS.sel_calcDrawInfo_1, aRect);
- }
-
- public NSInteger cellAttribute (objc.id aParameter)
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_cellAttribute_1, aParameter);
- }
-
- public NSSize cellSize ()
- {
- NSSize result;
- OS.objc_msgSend_struct(&result, this.id_, OS.sel_cellSize);
- return result;
- }
-
- public NSSize cellSizeForBounds (NSRect aRect)
- {
- NSSize result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_cellSizeForBounds_1, aRect);
- return result;
- }
+public this() {
+ super();
+}
- public objc.id compare (id otherCell)
- {
- return OS.objc_msgSend(this.id_, OS.sel_compare_1, otherCell !is null ? otherCell.id_ : null);
- }
-
- public bool continueTracking (NSPoint lastPoint, NSPoint currentPoint, NSView controlView)
- {
- return OS.objc_msgSend(this.id_, OS.sel_continueTracking_1at_1inView_1, lastPoint, currentPoint, controlView !is null ? controlView.id_ : null) !is null;
- }
-
- public objc.id controlSize ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_controlSize);
- }
-
- public objc.id controlTint ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_controlTint);
- }
-
- public NSView controlView ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_controlView);
- return result !is null ? new NSView(result) : null;
- }
-
- public static objc.id defaultFocusRingType ()
- {
- return OS.objc_msgSend(OS.class_NSCell, OS.sel_defaultFocusRingType);
- }
-
- public static NSMenu defaultMenu ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCell, OS.sel_defaultMenu);
- return result !is null ? new NSMenu(result) : null;
- }
-
- public double doubleValue ()
- {
- return OS.objc_msgSend_fpret(this.id_, OS.sel_doubleValue);
- }
-
- public void drawInteriorWithFrame (NSRect cellFrame, NSView controlView)
- {
- OS.objc_msgSend(this.id_, OS.sel_drawInteriorWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id_ : null);
- }
+public this(objc.id id) {
+ super(id);
+}
- public void drawWithExpansionFrame (NSRect cellFrame, NSView view)
- {
- OS.objc_msgSend(this.id_, OS.sel_drawWithExpansionFrame_1inView_1, cellFrame, view !is null ? view.id_ : null);
- }
-
- public void drawWithFrame (NSRect cellFrame, NSView controlView)
- {
- OS.objc_msgSend(this.id_, OS.sel_drawWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id_ : null);
- }
-
- public NSRect drawingRectForBounds (NSRect theRect)
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_drawingRectForBounds_1, theRect);
- return result;
- }
-
- public void editWithFrame (NSRect aRect, NSView controlView, NSText textObj, id anObject, NSEvent theEvent)
- {
- OS.objc_msgSend(this.id_, OS.sel_editWithFrame_1inView_1editor_1delegate_1event_1, aRect, controlView !is null ? controlView.id_ : null,
- textObj !is null ? textObj.id_ : null, anObject !is null ? anObject.id_ : null, theEvent !is null ? theEvent.id_ : null);
- }
-
- public void endEditing (NSText textObj)
- {
- OS.objc_msgSend(this.id_, OS.sel_endEditing_1, textObj !is null ? textObj.id_ : null);
- }
-
- public NSInteger entryType ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_entryType);
- }
-
- public NSRect expansionFrameWithFrame (NSRect cellFrame, NSView view)
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_expansionFrameWithFrame_1inView_1, cellFrame, view !is null ? view.id_ : null);
- return result;
- }
-
- public float floatValue ()
- {
- return cast(float) OS.objc_msgSend_fpret(this.id_, OS.sel_floatValue);
- }
-
- public objc.id focusRingType ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_focusRingType);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public NSFont font ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_font);
- return result !is null ? new NSFont(result) : null;
- }
-
- public id formatter ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_formatter);
- return result !is null ? new id(result) : null;
- }
-
- public void getPeriodicDelay (float* delay, float* interval)
- {
- OS.objc_msgSend(this.id_, OS.sel_getPeriodicDelay_1interval_1, delay, interval);
- }
-
- public bool hasValidObjectValue ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_hasValidObjectValue) !is null;
- }
-
- public void highlight (bool flag, NSRect cellFrame, NSView controlView)
- {
- OS.objc_msgSend(this.id_, OS.sel_highlight_1withFrame_1inView_1, flag, cellFrame, controlView !is null ? controlView.id_ : null);
- }
-
- public NSColor highlightColorWithFrame (NSRect cellFrame, NSView controlView)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_highlightColorWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id_ : null);
- return result !is null ? new NSColor(result) : null;
- }
-
- public NSUInteger hitTestForEvent (NSEvent event, NSRect cellFrame, NSView controlView)
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_hitTestForEvent_1inRect_1ofView_1, event !is null ? event.id_ : null, cellFrame,
- controlView !is null ? controlView.id_ : null);
- }
-
- public NSImage image ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_image);
- return result !is null ? new NSImage(result) : null;
- }
+public NSSize cellSizeForBounds(NSRect aRect) {
+ NSSize result = NSSize();
+ OS.objc_msgSend_stret(result, this.id, OS.sel_cellSizeForBounds_, aRect);
+ return result;
+}
- public NSRect imageRectForBounds (NSRect theRect)
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_imageRectForBounds_1, theRect);
- return result;
- }
-
- public bool importsGraphics ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_importsGraphics) !is null;
- }
-
- public NSCell initImageCell (NSImage image)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initImageCell_1, image !is null ? image.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSCell initTextCell (NSString aString)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initTextCell_1, aString !is null ? aString.id_ : null);
- return result !is null ? this : null;
- }
-
- public int intValue ()
- {
- return cast(int) OS.objc_msgSend(this.id_, OS.sel_intValue);
- }
-
- public NSInteger integerValue ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_integerValue);
- }
-
- public objc.id interiorBackgroundStyle ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_interiorBackgroundStyle);
- }
-
- public bool isBezeled ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isBezeled) !is null;
- }
-
- public bool isBordered ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isBordered) !is null;
- }
+public void drawInteriorWithFrame(NSRect cellFrame, NSView controlView) {
+ OS.objc_msgSend(this.id, OS.sel_drawInteriorWithFrame_inView_, cellFrame, controlView !is null ? controlView.id : null);
+}
- public bool isContinuous ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isContinuous) !is null;
- }
-
- public bool isEditable ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isEditable) !is null;
- }
-
- public bool isEnabled ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isEnabled) !is null;
- }
-
- public bool isEntryAcceptable (NSString aString)
- {
- return OS.objc_msgSend(this.id_, OS.sel_isEntryAcceptable_1, aString !is null ? aString.id_ : null) !is null;
- }
-
- public bool isHighlighted ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isHighlighted) !is null;
- }
-
- public bool isOpaque ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isOpaque) !is null;
- }
-
- public bool isScrollable ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isScrollable) !is null;
- }
-
- public bool isSelectable ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isSelectable) !is null;
- }
-
- public NSString keyEquivalent ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_keyEquivalent);
- return result !is null ? new NSString(result) : null;
- }
+public NSRect drawingRectForBounds(NSRect theRect) {
+ NSRect result = NSRect();
+ OS.objc_msgSend_stret(result, this.id, OS.sel_drawingRectForBounds_, theRect);
+ return result;
+}
- public objc.id lineBreakMode ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_lineBreakMode);
- }
-
- public NSMenu menu ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_menu);
- return result !is null ? new NSMenu(result) : null;
- }
-
- public NSMenu menuForEvent (NSEvent event, NSRect cellFrame, NSView view)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_menuForEvent_1inRect_1ofView_1, event !is null ? event.id_ : null, cellFrame,
- view !is null ? view.id_ : null);
- return result !is null ? new NSMenu(result) : null;
- }
-
- public NSString mnemonic ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_mnemonic);
- return result !is null ? new NSString(result) : null;
- }
+public NSFont font() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_font);
+ return result !is null ? new NSFont(result) : null;
+}
- public NSUInteger mnemonicLocation ()
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_mnemonicLocation);
- }
-
- public NSInteger mouseDownFlags ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_mouseDownFlags);
- }
-
- public NSInteger nextState ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_nextState);
- }
-
- public id objectValue ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectValue);
- return result !is null ? new id(result) : null;
- }
-
- public void performClick (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_performClick_1, sender !is null ? sender.id_ : null);
- }
-
- public static bool prefersTrackingUntilMouseUp ()
- {
- return OS.objc_msgSend(OS.class_NSCell, OS.sel_prefersTrackingUntilMouseUp) !is null;
- }
+public void setAllowsMixedState(bool flag) {
+ OS.objc_msgSend(this.id, OS.sel_setAllowsMixedState_, flag);
+}
- public bool refusesFirstResponder ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_refusesFirstResponder) !is null;
- }
-
- public id representedObject ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_representedObject);
- return result !is null ? new id(result) : null;
- }
-
- public void resetCursorRect (NSRect cellFrame, NSView controlView)
- {
- OS.objc_msgSend(this.id_, OS.sel_resetCursorRect_1inView_1, cellFrame, controlView !is null ? controlView.id_ : null);
- }
-
- public void selectWithFrame (NSRect aRect, NSView controlView, NSText textObj, id anObject, NSInteger selStart, NSInteger selLength)
- {
- OS.objc_msgSend(this.id_, OS.sel_selectWithFrame_1inView_1editor_1delegate_1start_1length_1, aRect,
- controlView !is null ? controlView.id_ : null, textObj !is null ? textObj.id_ : null, anObject !is null ? anObject.id_ : null, selStart,
- selLength);
- }
-
- public NSInteger sendActionOn (NSInteger mask)
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_sendActionOn_1, mask);
- }
-
- public bool sendsActionOnEndEditing ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_sendsActionOnEndEditing) !is null;
- }
-
- public void setAction (objc.SEL aSelector)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector);
- }
-
- public void setAlignment (objc.id mode)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAlignment_1, mode);
- }
+public void setAttributedStringValue(NSAttributedString obj) {
+ OS.objc_msgSend(this.id, OS.sel_setAttributedStringValue_, obj !is null ? obj.id : null);
+}
- public void setAllowsEditingTextAttributes (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAllowsEditingTextAttributes_1, flag);
- }
-
- public void setAllowsMixedState (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAllowsMixedState_1, flag);
- }
-
- public void setAllowsUndo (bool allowsUndo)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAllowsUndo_1, allowsUndo);
- }
-
- public void setAttributedStringValue (NSAttributedString obj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAttributedStringValue_1, obj !is null ? obj.id_ : null);
- }
-
- public void setBackgroundStyle (objc.id style)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBackgroundStyle_1, style);
- }
-
- public void setBaseWritingDirection (objc.id writingDirection)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBaseWritingDirection_1, writingDirection);
- }
-
- public void setBezeled (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBezeled_1, flag);
- }
-
- public void setBordered (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBordered_1, flag);
- }
-
- public void setCellAttribute (NSCellAttribute aParameter, NSInteger value)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCellAttribute_1to_1, aParameter, value);
- }
-
- public void setContinuous (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setContinuous_1, flag);
- }
+public void setFont(NSFont fontObj) {
+ OS.objc_msgSend(this.id, OS.sel_setFont_, fontObj !is null ? fontObj.id : null);
+}
- public void setControlSize (objc.id size)
- {
- OS.objc_msgSend(this.id_, OS.sel_setControlSize_1, size);
- }
-
- public void setControlTint (objc.id controlTint)
- {
- OS.objc_msgSend(this.id_, OS.sel_setControlTint_1, controlTint);
- }
-
- public void setControlView (NSView view)
- {
- OS.objc_msgSend(this.id_, OS.sel_setControlView_1, view !is null ? view.id_ : null);
- }
-
- public void setDoubleValue (double aDouble)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDoubleValue_1, aDouble);
- }
-
- public void setEditable (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setEditable_1, flag);
- }
-
- public void setEnabled (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setEnabled_1, flag);
- }
-
- public void setEntryType (NSInteger aType)
- {
- OS.objc_msgSend(this.id_, OS.sel_setEntryType_1, aType);
- }
-
- public void setFloatValue (float aFloat)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFloatValue_1, aFloat);
- }
-
- public void setFloatingPointFormat (bool autoRange, NSUInteger leftDigits, NSUInteger rightDigits)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFloatingPointFormat_1left_1right_1, autoRange, leftDigits, rightDigits);
- }
-
- public void setFocusRingType (objc.id focusRingType)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFocusRingType_1, focusRingType);
- }
+public void setFormatter(NSFormatter newFormatter) {
+ OS.objc_msgSend(this.id, OS.sel_setFormatter_, newFormatter !is null ? newFormatter.id : null);
+}
- public void setFont (NSFont fontObj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFont_1, fontObj !is null ? fontObj.id_ : null);
- }
-
- public void setFormatter (NSFormatter newFormatter)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFormatter_1, newFormatter !is null ? newFormatter.id_ : null);
- }
-
- public void setHighlighted (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setHighlighted_1, flag);
- }
-
- public void setImage (NSImage image)
- {
- OS.objc_msgSend(this.id_, OS.sel_setImage_1, image !is null ? image.id_ : null);
- }
-
- public void setImportsGraphics (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setImportsGraphics_1, flag);
- }
+public void setHighlighted(bool flag) {
+ OS.objc_msgSend(this.id, OS.sel_setHighlighted_, flag);
+}
- public void setIntValue (int anInt)
- {
- OS.objc_msgSend(this.id_, OS.sel_setIntValue_1, anInt);
- }
-
- public void setIntegerValue (int anInteger)
- {
- OS.objc_msgSend(this.id_, OS.sel_setIntegerValue_1, anInteger);
- }
-
- public void setLineBreakMode (objc.id mode)
- {
- OS.objc_msgSend(this.id_, OS.sel_setLineBreakMode_1, mode);
- }
-
- public void setMenu (NSMenu aMenu)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMenu_1, aMenu !is null ? aMenu.id_ : null);
- }
-
- public void setMnemonicLocation (NSUInteger location)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMnemonicLocation_1, location);
- }
+public void setImage(NSImage image) {
+ OS.objc_msgSend(this.id, OS.sel_setImage_, image !is null ? image.id : null);
+}
- public void setNextState ()
- {
- OS.objc_msgSend(this.id_, OS.sel_setNextState);
- }
-
- public void setObjectValue (id obj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setObjectValue_1, obj !is null ? obj.id_ : null);
- }
-
- public void setRefusesFirstResponder (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setRefusesFirstResponder_1, flag);
- }
-
- public void setRepresentedObject (id anObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_setRepresentedObject_1, anObject !is null ? anObject.id_ : null);
- }
-
- public void setScrollable (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setScrollable_1, flag);
- }
-
- public void setSelectable (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setSelectable_1, flag);
- }
-
- public void setSendsActionOnEndEditing (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setSendsActionOnEndEditing_1, flag);
- }
-
- public void setShowsFirstResponder (bool showFR)
- {
- OS.objc_msgSend(this.id_, OS.sel_setShowsFirstResponder_1, showFR);
- }
-
- public void setState (NSInteger value)
- {
- OS.objc_msgSend(this.id_, OS.sel_setState_1, value);
- }
+public void setTitle(NSString aString) {
+ OS.objc_msgSend(this.id, OS.sel_setTitle_, aString !is null ? aString.id : null);
+}
- public void setStringValue (NSString aString)
- {
- OS.objc_msgSend(this.id_, OS.sel_setStringValue_1, aString !is null ? aString.id_ : null);
- }
-
- public void setTag (NSInteger anInt)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTag_1, anInt);
- }
-
- public void setTarget (id anObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTarget_1, anObject !is null ? anObject.id_ : null);
- }
-
- public void setTitle (NSString aString)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTitle_1, aString !is null ? aString.id_ : null);
- }
-
- public void setTitleWithMnemonic (NSString StringWithAmpersand)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTitleWithMnemonic_1, StringWithAmpersand !is null ? StringWithAmpersand.id_ : null);
- }
-
- public void setTruncatesLastVisibleLine (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTruncatesLastVisibleLine_1, flag);
- }
-
- public void setType (objc.id aType)
- {
- OS.objc_msgSend(this.id_, OS.sel_setType_1, aType);
- }
-
- public NSText setUpFieldEditorAttributes (NSText textObj)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_setUpFieldEditorAttributes_1, textObj !is null ? textObj.id_ : null);
- return result !is null ? new NSText(result) : null;
- }
-
- public void setWraps (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setWraps_1, flag);
- }
-
- public bool showsFirstResponder ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_showsFirstResponder) !is null;
- }
+public void setWraps(bool flag) {
+ OS.objc_msgSend(this.id, OS.sel_setWraps_, flag);
+}
- public bool startTrackingAt (NSPoint startPoint, NSView controlView)
- {
- return OS.objc_msgSend(this.id_, OS.sel_startTrackingAt_1inView_1, startPoint, controlView !is null ? controlView.id_ : null) !is null;
- }
-
- public NSInteger state ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_state);
- }
-
- public void stopTracking (NSPoint lastPoint, NSPoint stopPoint, NSView controlView, bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_stopTracking_1at_1inView_1mouseIsUp_1, lastPoint, stopPoint, controlView !is null ? controlView.id_ : null,
- flag);
- }
-
- public NSString StringValue ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_stringValue);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSInteger tag ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_tag);
- }
-
- public void takeDoubleValueFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeDoubleValueFrom_1, sender !is null ? sender.id_ : null);
- }
-
- public void takeFloatValueFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeFloatValueFrom_1, sender !is null ? sender.id_ : null);
- }
-
- public void takeIntValueFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeIntValueFrom_1, sender !is null ? sender.id_ : null);
- }
-
- public void takeIntegerValueFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeIntegerValueFrom_1, sender !is null ? sender.id_ : null);
- }
+public NSString title() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+ return result !is null ? new NSString(result) : null;
+}
- public void takeObjectValueFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeObjectValueFrom_1, sender !is null ? sender.id_ : null);
- }
-
- public void takeStringValueFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeStringValueFrom_1, sender !is null ? sender.id_ : null);
- }
-
- public id target ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_target);
- return result !is null ? new id(result) : null;
- }
-
- public NSString title ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_title);
- return result !is null ? new NSString(result) : null;
- }
+public NSRect titleRectForBounds(NSRect theRect) {
+ NSRect result = NSRect();
+ OS.objc_msgSend_stret(result, this.id, OS.sel_titleRectForBounds_, theRect);
+ return result;
+}
- public NSRect titleRectForBounds (NSRect theRect)
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_titleRectForBounds_1, theRect);
- return result;
- }
-
- public bool trackMouse (NSEvent theEvent, NSRect cellFrame, NSView controlView, bool flag)
- {
- return OS.objc_msgSend(this.id_, OS.sel_trackMouse_1inRect_1ofView_1untilMouseUp_1, theEvent !is null ? theEvent.id_ : null, cellFrame,
- controlView !is null ? controlView.id_ : null, flag) !is null;
- }
-
- public bool truncatesLastVisibleLine ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_truncatesLastVisibleLine) !is null;
- }
-
- public objc.id type ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_type);
- }
-
- public bool wantsNotificationForMarkedText ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_wantsNotificationForMarkedText) !is null;
- }
-
- public bool wraps ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_wraps) !is null;
- }
+public bool wraps() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_wraps);
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCharacterSet.d
--- a/dwt/internal/cocoa/NSCharacterSet.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSCharacterSet.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,183 +1,45 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSCharacterSet;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSData;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSRange;
-import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
-public class NSCharacterSet : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public static id alphanumericCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_alphanumericCharacterSet);
- return result !is null ? new id(result) : null;
- }
-
- public NSData bitmapRepresentation ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_bitmapRepresentation);
- return result !is null ? new NSData(result) : null;
- }
-
- public static id capitalizedLetterCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_capitalizedLetterCharacterSet);
- return result !is null ? new id(result) : null;
- }
-
- public bool characterIsMember (short aCharacter)
- {
- return OS.objc_msgSend(this.id_, OS.sel_characterIsMember_1, aCharacter) !is null;
- }
+public class NSCharacterSet : NSObject {
- public static id characterSetWithBitmapRepresentation (NSData data)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_characterSetWithBitmapRepresentation_1, data !is null ? data.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id characterSetWithCharactersInString (NSString aString)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_characterSetWithCharactersInString_1, aString !is null ? aString.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id characterSetWithContentsOfFile (NSString fName)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_characterSetWithContentsOfFile_1, fName !is null ? fName.id_ : null);
- return result !is null ? new id(result) : null;
- }
+public this() {
+ super();
+}
- public static id characterSetWithRange (NSRange aRange)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_characterSetWithRange_1, aRange);
- return result !is null ? new id(result) : null;
- }
-
- public static id controlCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_controlCharacterSet);
- return result !is null ? new id(result) : null;
- }
-
- public static id decimalDigitCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_decimalDigitCharacterSet);
- return result !is null ? new id(result) : null;
- }
-
- public static id decomposableCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_decomposableCharacterSet);
- return result !is null ? new id(result) : null;
- }
+public this(objc.id id) {
+ super(id);
+}
- public bool hasMemberInPlane (byte thePlane)
- {
- return OS.objc_msgSend(this.id_, OS.sel_hasMemberInPlane_1, thePlane) !is null;
- }
-
- public static id illegalCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_illegalCharacterSet);
- return result !is null ? new id(result) : null;
- }
-
- public NSCharacterSet invertedSet ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_invertedSet);
- return result is this.id_ ? this : (result !is null ? new NSCharacterSet(result) : null);
- }
-
- public bool isSupersetOfSet (NSCharacterSet theOtherSet)
- {
- return OS.objc_msgSend(this.id_, OS.sel_isSupersetOfSet_1, theOtherSet !is null ? theOtherSet.id_ : null) !is null;
- }
-
- public static id letterCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_letterCharacterSet);
- return result !is null ? new id(result) : null;
- }
-
- public bool longCharacterIsMember (dchar theLongChar)
- {
- return OS.objc_msgSend(this.id_, OS.sel_longCharacterIsMember_1, theLongChar) !is null;
- }
-
- public static id lowercaseLetterCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_lowercaseLetterCharacterSet);
- return result !is null ? new id(result) : null;
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public static id newlineCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_newlineCharacterSet);
- return result !is null ? new id(result) : null;
- }
-
- public static id nonBaseCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_nonBaseCharacterSet);
- return result !is null ? new id(result) : null;
- }
-
- public static id punctuationCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_punctuationCharacterSet);
- return result !is null ? new id(result) : null;
- }
+public bool characterIsMember(wchar aCharacter) {
+ return OS.objc_msgSend_bool(this.id, OS.sel_characterIsMember_, aCharacter);
+}
- public static id symbolCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_symbolCharacterSet);
- return result !is null ? new id(result) : null;
- }
-
- public static id uppercaseLetterCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_uppercaseLetterCharacterSet);
- return result !is null ? new id(result) : null;
- }
-
- public static id whitespaceAndNewlineCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_whitespaceAndNewlineCharacterSet);
- return result !is null ? new id(result) : null;
- }
-
- public static id whitespaceCharacterSet ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_whitespaceCharacterSet);
- return result !is null ? new id(result) : null;
- }
+public static cocoa.id decimalDigitCharacterSet() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_decimalDigitCharacterSet);
+ return result !is null ? new cocoa.id(result) : null;
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSClassDescription.d
--- a/dwt/internal/cocoa/NSClassDescription.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSClassDescription;
-
-import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSClassDescription : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSArray attributeKeys ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributeKeys);
- return result !is null ? new NSArray(result) : null;
- }
-
- public static NSClassDescription classDescriptionForClass (objc.Class aClass)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSClassDescription, OS.sel_classDescriptionForClass_1, aClass);
- return result !is null ? new NSClassDescription(result) : null;
- }
-
- public static void invalidateClassDescriptionCache ()
- {
- OS.objc_msgSend(OS.class_NSClassDescription, OS.sel_invalidateClassDescriptionCache);
- }
-
- public NSString inverseForRelationshipKey (NSString relationshipKey)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_inverseForRelationshipKey_1, relationshipKey !is null ? relationshipKey.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public static void registerClassDescription (NSClassDescription description, objc.Class aClass)
- {
- OS.objc_msgSend(OS.class_NSClassDescription, OS.sel_registerClassDescription_1forClass_1, description !is null ? description.id_ : null,
- aClass);
- }
-
- public NSArray toManyRelationshipKeys ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_toManyRelationshipKeys);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray toOneRelationshipKeys ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_toOneRelationshipKeys);
- return result !is null ? new NSArray(result) : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSClipView.d
--- a/dwt/internal/cocoa/NSClipView.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSClipView.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,134 +1,41 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSClipView;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSColor;
-import dwt.internal.cocoa.NSCursor;
-import dwt.internal.cocoa.NSEvent;
-import dwt.internal.cocoa.NSNotification;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSPoint;
-import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
-public class NSClipView : NSView
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public bool autoscroll (NSEvent theEvent)
- {
- return OS.objc_msgSend(this.id_, OS.sel_autoscroll_1, theEvent !is null ? theEvent.id_ : null) !is null;
- }
-
- public NSColor backgroundColor ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_backgroundColor);
- return result !is null ? new NSColor(result) : null;
- }
+public class NSClipView : NSView {
- public NSPoint constrainScrollPoint (NSPoint newOrigin)
- {
- NSPoint result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_constrainScrollPoint_1, newOrigin);
- return result;
- }
-
- public bool copiesOnScroll ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_copiesOnScroll) !is null;
- }
-
- public NSCursor documentCursor ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_documentCursor);
- return result !is null ? new NSCursor(result) : null;
- }
-
- public NSRect documentRect ()
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_documentRect);
- return result;
- }
+public this() {
+ super();
+}
- public id documentView ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_documentView);
- return result !is null ? new id(result) : null;
- }
-
- public NSRect documentVisibleRect ()
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_documentVisibleRect);
- return result;
- }
-
- public bool drawsBackground ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_drawsBackground) !is null;
- }
-
- public void scrollToPoint (NSPoint newOrigin)
- {
- OS.objc_msgSend(this.id_, OS.sel_scrollToPoint_1, newOrigin);
- }
-
- public void setBackgroundColor (NSColor color)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBackgroundColor_1, color !is null ? color.id_ : null);
- }
+public this(objc.id id) {
+ super(id);
+}
- public void setCopiesOnScroll (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCopiesOnScroll_1, flag);
- }
-
- public void setDocumentCursor (NSCursor anObj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDocumentCursor_1, anObj !is null ? anObj.id_ : null);
- }
-
- public void setDocumentView (NSView aView)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDocumentView_1, aView !is null ? aView.id_ : null);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public void setDrawsBackground (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDrawsBackground_1, flag);
- }
-
- public void viewBoundsChanged (NSNotification notification)
- {
- OS.objc_msgSend(this.id_, OS.sel_viewBoundsChanged_1, notification !is null ? notification.id_ : null);
- }
-
- public void viewFrameChanged (NSNotification notification)
- {
- OS.objc_msgSend(this.id_, OS.sel_viewFrameChanged_1, notification !is null ? notification.id_ : null);
- }
+public void scrollToPoint(NSPoint newOrigin) {
+ OS.objc_msgSend(this.id, OS.sel_scrollToPoint_, newOrigin);
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCloneCommand.d
--- a/dwt/internal/cocoa/NSCloneCommand.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSCloneCommand;
-
-import dwt.internal.cocoa.NSScriptCommand;
-import dwt.internal.cocoa.NSScriptObjectSpecifier;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSCloneCommand : NSScriptCommand
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSScriptObjectSpecifier keySpecifier ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_keySpecifier);
- return result !is null ? new NSScriptObjectSpecifier(result) : null;
- }
-
- public void setReceiversSpecifier (NSScriptObjectSpecifier receiversRef)
- {
- OS.objc_msgSend(this.id_, OS.sel_setReceiversSpecifier_1, receiversRef !is null ? receiversRef.id_ : null);
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCloseCommand.d
--- a/dwt/internal/cocoa/NSCloseCommand.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSCloseCommand;
-
-import dwt.internal.cocoa.NSScriptCommand;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-enum NSSaveOptions
-{
- NSSaveOptionsYes = 0,
- NSSaveOptionsNo,
- NSSaveOptionsAsk
-}
-
-alias NSSaveOptions.NSSaveOptionsYes NSSaveOptionsYes;
-alias NSSaveOptions.NSSaveOptionsNo NSSaveOptionsNo;
-alias NSSaveOptions.NSSaveOptionsAsk NSSaveOptionsAsk;
-
-public class NSCloseCommand : NSScriptCommand
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSSaveOptions saveOptions ()
- {
- return cast(NSSaveOptions) OS.objc_msgSend(this.id_, OS.sel_saveOptions);
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCoder.d
--- a/dwt/internal/cocoa/NSCoder.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSCoder.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,341 +1,40 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSCoder;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSData;
-import dwt.internal.cocoa.NSInteger;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSPoint;
-import dwt.internal.cocoa.NSRect;
-import dwt.internal.cocoa.NSSize;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.NSZone;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
-public class NSCoder : NSObject
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public bool allowsKeyedCoding ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_allowsKeyedCoding) !is null;
- }
-
- public bool containsValueForKey (NSString key)
- {
- return OS.objc_msgSend(this.id_, OS.sel_containsValueForKey_1, key !is null ? key.id_ : null) !is null;
- }
-
- public void decodeArrayOfObjCType (/*const*/char* itemType, NSUInteger count, void* array)
- {
- OS.objc_msgSend(this.id_, OS.sel_decodeArrayOfObjCType_1count_1at_1, itemType, count, array);
- }
-
- public bool decodeBoolForKey (NSString key)
- {
- return OS.objc_msgSend(this.id_, OS.sel_decodeBoolForKey_1, key !is null ? key.id_ : null) !is null;
- }
-
- public /*const*/ubyte* decodeBytesForKey (NSString key, NSUInteger* lengthp)
- {
- return cast(/*const*/ubyte*) OS.objc_msgSend(this.id_, OS.sel_decodeBytesForKey_1returnedLength_1, key !is null ? key.id_ : null, lengthp);
- }
-
- public void* decodeBytesWithReturnedLength (NSUInteger* lengthp)
- {
- return cast(void*) OS.objc_msgSend(this.id_, OS.sel_decodeBytesWithReturnedLength_1, lengthp);
- }
-
- public NSData decodeDataObject ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_decodeDataObject);
- return result !is null ? new NSData(result) : null;
- }
-
- public double decodeDoubleForKey (NSString key)
- {
- return OS.objc_msgSend_fpret(this.id_, OS.sel_decodeDoubleForKey_1, key !is null ? key.id_ : null);
- }
-
- public float decodeFloatForKey (NSString key)
- {
- return cast(float) OS.objc_msgSend_fpret(this.id_, OS.sel_decodeFloatForKey_1, key !is null ? key.id_ : null);
- }
-
- public int decodeInt32ForKey (NSString key)
- {
- return cast(int) OS.objc_msgSend(this.id_, OS.sel_decodeInt32ForKey_1, key !is null ? key.id_ : null);
- }
-
- public long decodeInt64ForKey (NSString key)
- {
- return cast(long) OS.objc_msgSend(this.id_, OS.sel_decodeInt64ForKey_1, key !is null ? key.id_ : null);
- }
-
- public int decodeIntForKey (NSString key)
- {
- return cast(int) OS.objc_msgSend(this.id_, OS.sel_decodeIntForKey_1, key !is null ? key.id_ : null);
- }
+public class NSCoder : NSObject {
- public NSInteger decodeIntegerForKey (NSString key)
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_decodeIntegerForKey_1, key !is null ? key.id_ : null);
- }
-
- public id decodeNXObject ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_decodeNXObject);
- return result !is null ? new id(result) : null;
- }
-
- public id decodeObject ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_decodeObject);
- return result !is null ? new id(result) : null;
- }
-
- public id decodeObjectForKey (NSString key)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_decodeObjectForKey_1, key !is null ? key.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public NSPoint decodePoint ()
- {
- NSPoint result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_decodePoint);
- return result;
- }
-
- public NSPoint decodePointForKey (NSString key)
- {
- NSPoint result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_decodePointForKey_1, key !is null ? key.id_ : null);
- return result;
- }
+public this() {
+ super();
+}
- public id decodePropertyList ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_decodePropertyList);
- return result !is null ? new id(result) : null;
- }
-
- public NSRect decodeRect ()
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_decodeRect);
- return result;
- }
-
- public NSRect decodeRectForKey (NSString key)
- {
- NSRect result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_decodeRectForKey_1, key !is null ? key.id_ : null);
- return result;
- }
-
- public NSSize decodeSize ()
- {
- NSSize result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_decodeSize);
- return result;
- }
-
- public NSSize decodeSizeForKey (NSString key)
- {
- NSSize result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_decodeSizeForKey_1, key !is null ? key.id_ : null);
- return result;
- }
-
- public void decodeValueOfObjCType (/*const*/char* type, void* data)
- {
- OS.objc_msgSend(this.id_, OS.sel_decodeValueOfObjCType_1at_1, type, data);
- }
-
- public void decodeValuesOfObjCTypes (/*const*/char* decodeValuesOfObjCTypes)
- {
- OS.objc_msgSend(this.id_, OS.sel_decodeValuesOfObjCTypes_1, decodeValuesOfObjCTypes);
- }
+public this(objc.id id) {
+ super(id);
+}
- public void encodeArrayOfObjCType (/*const*/char* type, NSUInteger count, void* array)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeArrayOfObjCType_1count_1at_1, type, count, array);
- }
-
- public void encodeBool (bool boolv, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeBool_1forKey_1, boolv, key !is null ? key.id_ : null);
- }
-
- public void encodeBycopyObject (id anObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeBycopyObject_1, anObject !is null ? anObject.id_ : null);
- }
-
- public void encodeByrefObject (id anObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeByrefObject_1, anObject !is null ? anObject.id_ : null);
- }
-
- public void encodeBytes_length_ (/*const*/void* byteaddr, NSUInteger length)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeBytes_1length_1, byteaddr, length);
- }
-
- public void encodeBytes_length_forKey_ (byte* bytesp, NSUInteger lenv, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeBytes_1length_1forKey_1, bytesp, lenv, key !is null ? key.id_ : null);
- }
-
- public void encodeConditionalObject_ (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeConditionalObject_1, object !is null ? object.id_ : null);
- }
-
- public void encodeConditionalObject_forKey_ (id objv, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeConditionalObject_1forKey_1, objv !is null ? objv.id_ : null, key !is null ? key.id_ : null);
- }
-
- public void encodeDataObject (NSData data)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeDataObject_1, data !is null ? data.id_ : null);
- }
-
- public void encodeDouble (double realv, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeDouble_1forKey_1, realv, key !is null ? key.id_ : null);
- }
-
- public void encodeFloat (float realv, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeFloat_1forKey_1, realv, key !is null ? key.id_ : null);
- }
-
- public void encodeInt32 (int intv, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeInt32_1forKey_1, intv, key !is null ? key.id_ : null);
- }
-
- public void encodeInt64 (long intv, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeInt64_1forKey_1, intv, key !is null ? key.id_ : null);
- }
-
- public void encodeInt (int intv, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeInt_1forKey_1, intv, key !is null ? key.id_ : null);
- }
-
- public void encodeInteger (NSInteger intv, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeInteger_1forKey_1, intv, key !is null ? key.id_ : null);
- }
-
- public void encodeNXObject (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeNXObject_1, object !is null ? object.id_ : null);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public void encodeObject_ (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeObject_1, object !is null ? object.id_ : null);
- }
-
- public void encodeObject_forKey_ (id objv, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeObject_1forKey_1, objv !is null ? objv.id_ : null, key !is null ? key.id_ : null);
- }
-
- public void encodePoint_ (NSPoint point)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodePoint_1, point);
- }
-
- public void encodePoint_forKey_ (NSPoint point, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodePoint_1forKey_1, point, key !is null ? key.id_ : null);
- }
-
- public void encodePropertyList (id aPropertyList)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodePropertyList_1, aPropertyList !is null ? aPropertyList.id_ : null);
- }
-
- public void encodeRect_ (NSRect rect)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeRect_1, rect);
- }
-
- public void encodeRect_forKey_ (NSRect rect, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeRect_1forKey_1, rect, key !is null ? key.id_ : null);
- }
-
- public void encodeRootObject (id rootObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeRootObject_1, rootObject !is null ? rootObject.id_ : null);
- }
+public int systemVersion() {
+ return cast(int)/*64*/OS.objc_msgSend(this.id, OS.sel_systemVersion);
+}
- public void encodeSize_ (NSSize size)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeSize_1, size);
- }
-
- public void encodeSize_forKey_ (NSSize size, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeSize_1forKey_1, size, key !is null ? key.id_ : null);
- }
-
- public void encodeValueOfObjCType (/*const*/char* type, void* addr)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeValueOfObjCType_1at_1, type, addr);
- }
-
- public void encodeValuesOfObjCTypes (/*const*/char* encodeValuesOfObjCTypes)
- {
- OS.objc_msgSend(this.id_, OS.sel_encodeValuesOfObjCTypes_1, encodeValuesOfObjCTypes);
- }
-
- public NSZone* objectZone ()
- {
- return cast(NSZone*) OS.objc_msgSend(this.id_, OS.sel_objectZone);
- }
-
- public void setObjectZone (objc.id zone)
- {
- OS.objc_msgSend(this.id_, OS.sel_setObjectZone_1, zone);
- }
-
- public uint systemVersion ()
- {
- return cast(uint) OS.objc_msgSend(this.id_, OS.sel_systemVersion);
- }
-
- public NSInteger versionForClassName (NSString className)
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_versionForClassName_1, className !is null ? className.id_ : null);
- }
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCollectionView.d
--- a/dwt/internal/cocoa/NSCollectionView.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSCollectionView;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSCollectionViewItem;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSIndexSet;
-import dwt.internal.cocoa.NSSize;
-import dwt.internal.cocoa.NSView;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSCollectionView : NSView
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public bool allowsMultipleSelection ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_allowsMultipleSelection) !is null;
- }
-
- public NSArray backgroundColors ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_backgroundColors);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray content ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_content);
- return result !is null ? new NSArray(result) : null;
- }
-
- public bool isFirstResponder ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isFirstResponder) !is null;
- }
-
- public bool isSelectable ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isSelectable) !is null;
- }
-
- public NSCollectionViewItem itemPrototype ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_itemPrototype);
- return result !is null ? new NSCollectionViewItem(result) : null;
- }
-
- public NSSize maxItemSize ()
- {
- NSSize result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_maxItemSize);
- return result;
- }
-
- public NSUInteger maxNumberOfColumns ()
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_maxNumberOfColumns);
- }
-
- public NSUInteger maxNumberOfRows ()
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_maxNumberOfRows);
- }
-
- public NSSize minItemSize ()
- {
- NSSize result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_minItemSize);
- return result;
- }
-
- public NSCollectionViewItem newItemForRepresentedObject (id object)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_newItemForRepresentedObject_1, object !is null ? object.id_ : null);
- return result !is null ? new NSCollectionViewItem(result) : null;
- }
-
- public NSIndexSet selectionIndexes ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectionIndexes);
- return result !is null ? new NSIndexSet(result) : null;
- }
-
- public void setAllowsMultipleSelection (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAllowsMultipleSelection_1, flag);
- }
-
- public void setBackgroundColors (NSArray colors)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBackgroundColors_1, colors !is null ? colors.id_ : null);
- }
-
- public void setContent (NSArray content)
- {
- OS.objc_msgSend(this.id_, OS.sel_setContent_1, content !is null ? content.id_ : null);
- }
-
- public void setItemPrototype (NSCollectionViewItem prototype)
- {
- OS.objc_msgSend(this.id_, OS.sel_setItemPrototype_1, prototype !is null ? prototype.id_ : null);
- }
-
- public void setMaxItemSize (NSSize size)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMaxItemSize_1, size);
- }
-
- public void setMaxNumberOfColumns (NSUInteger number)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMaxNumberOfColumns_1, number);
- }
-
- public void setMaxNumberOfRows (NSUInteger number)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMaxNumberOfRows_1, number);
- }
-
- public void setMinItemSize (NSSize size)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMinItemSize_1, size);
- }
-
- public void setSelectable (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setSelectable_1, flag);
- }
-
- public void setSelectionIndexes (NSIndexSet indexes)
- {
- OS.objc_msgSend(this.id_, OS.sel_setSelectionIndexes_1, indexes !is null ? indexes.id_ : null);
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCollectionViewItem.d
--- a/dwt/internal/cocoa/NSCollectionViewItem.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSCollectionViewItem;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSCollectionView;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSView;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSCollectionViewItem : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSCollectionView collectionView ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_collectionView);
- return result !is null ? new NSCollectionView(result) : null;
- }
-
- public bool isSelected ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isSelected) !is null;
- }
-
- public id representedObject ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_representedObject);
- return result !is null ? new id(result) : null;
- }
-
- public void setRepresentedObject (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_setRepresentedObject_1, object !is null ? object.id_ : null);
- }
-
- public void setSelected (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setSelected_1, flag);
- }
-
- public void setView (NSView view)
- {
- OS.objc_msgSend(this.id_, OS.sel_setView_1, view !is null ? view.id_ : null);
- }
-
- public NSView view ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_view);
- return result !is null ? new NSView(result) : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSColor.d
--- a/dwt/internal/cocoa/NSColor.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSColor.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,623 +1,187 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSColor;
-import dwt.internal.cocoa.CGFloat;
-import dwt.internal.cocoa.CIColor;
-import dwt.internal.cocoa.NSArray;
+import dwt.dwthelper.utils;
+import dwt.internal.c.Carbon;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSColorSpace;
-import dwt.internal.cocoa.NSDictionary;
import dwt.internal.cocoa.NSImage;
-import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSPasteboard;
-import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
-public class NSColor : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
+public class NSColor : NSObject {
- public CGFloat alphaComponent ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_alphaComponent);
- }
-
- public static NSColor alternateSelectedControlColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_alternateSelectedControlColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor alternateSelectedControlTextColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_alternateSelectedControlTextColor);
- return result !is null ? new NSColor(result) : null;
- }
+public this() {
+ super();
+}
- public static NSColor blackColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_blackColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public CGFloat blackComponent ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_blackComponent);
- }
-
- public NSColor blendedColorWithFraction (CGFloat fraction, NSColor color)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_blendedColorWithFraction_1ofColor_1, fraction, color !is null ? color.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSColor(result) : null);
- }
+public this(objc.id id) {
+ super(id);
+}
- public static NSColor blueColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_blueColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public CGFloat blueComponent ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_blueComponent);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public CGFloat brightnessComponent ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_brightnessComponent);
- }
-
- public static NSColor brownColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_brownColor);
- return result !is null ? new NSColor(result) : null;
- }
+public CGFloat alphaComponent() {
+ return cast(CGFloat)OS.objc_msgSend_fpret(this.id, OS.sel_alphaComponent);
+}
- public NSString catalogNameComponent ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_catalogNameComponent);
- return result !is null ? new NSString(result) : null;
- }
-
- public static NSColor clearColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_clearColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor colorForControlTint (objc.id controlTint)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorForControlTint_1, controlTint);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor colorFromPasteboard (NSPasteboard pasteBoard)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorFromPasteboard_1, pasteBoard !is null ? pasteBoard.id_ : null);
- return result !is null ? new NSColor(result) : null;
- }
-
- public NSString colorNameComponent ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_colorNameComponent);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSColorSpace colorSpace ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_colorSpace);
- return result !is null ? new NSColorSpace(result) : null;
- }
+public static NSColor alternateSelectedControlTextColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_alternateSelectedControlTextColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public NSString colorSpaceName ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_colorSpaceName);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSColor colorUsingColorSpace (NSColorSpace space)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_colorUsingColorSpace_1, space !is null ? space.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSColor(result) : null);
- }
-
- public NSColor colorUsingColorSpaceName_ (NSString colorSpace)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_colorUsingColorSpaceName_1, colorSpace !is null ? colorSpace.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSColor(result) : null);
- }
+public static NSColor blackColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_blackColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public NSColor colorUsingColorSpaceName_device_ (NSString colorSpace, NSDictionary deviceDescription)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_colorUsingColorSpaceName_1device_1, colorSpace !is null ? colorSpace.id_ : null,
- deviceDescription !is null ? deviceDescription.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSColor(result) : null);
- }
+public CGFloat blueComponent() {
+ return cast(CGFloat)OS.objc_msgSend_fpret(this.id, OS.sel_blueComponent);
+}
- public NSColor colorWithAlphaComponent (CGFloat alpha)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_colorWithAlphaComponent_1, alpha);
- return result is this.id_ ? this : (result !is null ? new NSColor(result) : null);
- }
-
- public static NSColor colorWithCIColor (CIColor color)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithCIColor_1, color !is null ? color.id_ : null);
- return result !is null ? new NSColor(result) : null;
- }
+public static NSColor clearColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_clearColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public static NSColor colorWithCalibratedHue (CGFloat hue, CGFloat saturation, CGFloat brightness, CGFloat alpha)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithCalibratedHue_1saturation_1brightness_1alpha_1, hue, saturation,
- brightness, alpha);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor colorWithCalibratedRed (CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithCalibratedRed_1green_1blue_1alpha_1, red, green, blue, alpha);
- return result !is null ? new NSColor(result) : null;
- }
+public NSColor colorUsingColorSpace(NSColorSpace space) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_colorUsingColorSpace_, space !is null ? space.id : null);
+ return result is this.id ? this : (result !is null ? new NSColor(result) : null);
+}
- public static NSColor colorWithCalibratedWhite (CGFloat white, CGFloat alpha)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithCalibratedWhite_1alpha_1, white, alpha);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor colorWithCatalogName (NSString listName, NSString colorName)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithCatalogName_1colorName_1, listName !is null ? listName.id_ : null,
- colorName !is null ? colorName.id_ : null);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor colorWithColorSpace (NSColorSpace space, /*const*/CGFloat* components, NSInteger numberOfComponents)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithColorSpace_1components_1count_1, space !is null ? space.id_ : null,
- components, numberOfComponents);
- return result !is null ? new NSColor(result) : null;
- }
+public NSColor colorUsingColorSpaceName(NSString colorSpace) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_colorUsingColorSpaceName_, colorSpace !is null ? colorSpace.id : null);
+ return result is this.id ? this : (result !is null ? new NSColor(result) : null);
+}
- public static NSColor colorWithDeviceCyan (CGFloat cyan, CGFloat magenta, CGFloat yellow, CGFloat black, CGFloat alpha)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithDeviceCyan_1magenta_1yellow_1black_1alpha_1, cyan, magenta, yellow, black,
- alpha);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor colorWithDeviceHue (CGFloat hue, CGFloat saturation, CGFloat brightness, CGFloat alpha)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithDeviceHue_1saturation_1brightness_1alpha_1, hue, saturation, brightness,
- alpha);
- return result !is null ? new NSColor(result) : null;
- }
+public static NSColor colorWithDeviceRed(CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha) {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithDeviceRed_green_blue_alpha_, red, green, blue, alpha);
+ return result !is null ? new NSColor(result) : null;
+}
- public static NSColor colorWithDeviceRed (CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithDeviceRed_1green_1blue_1alpha_1, red, green, blue, alpha);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor colorWithDeviceWhite (CGFloat white, CGFloat alpha)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithDeviceWhite_1alpha_1, white, alpha);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor colorWithPatternImage (NSImage image)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithPatternImage_1, image !is null ? image.id_ : null);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSArray controlAlternatingRowBackgroundColors ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlAlternatingRowBackgroundColors);
- return result !is null ? new NSArray(result) : null;
- }
+public static NSColor colorWithPatternImage(NSImage image) {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithPatternImage_, image !is null ? image.id : null);
+ return result !is null ? new NSColor(result) : null;
+}
- public static NSColor controlBackgroundColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlBackgroundColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor controlColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor controlDarkShadowColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlDarkShadowColor);
- return result !is null ? new NSColor(result) : null;
- }
+public static NSColor controlDarkShadowColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlDarkShadowColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public static NSColor controlHighlightColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlHighlightColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor controlLightHighlightColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlLightHighlightColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor controlShadowColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlShadowColor);
- return result !is null ? new NSColor(result) : null;
- }
+public static NSColor controlHighlightColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlHighlightColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public static NSColor controlTextColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlTextColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static objc.id currentControlTint ()
- {
- return OS.objc_msgSend(OS.class_NSColor, OS.sel_currentControlTint);
- }
-
- public static NSColor cyanColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_cyanColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public CGFloat cyanComponent ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_cyanComponent);
- }
+public static NSColor controlLightHighlightColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlLightHighlightColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public static NSColor darkGrayColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_darkGrayColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor disabledControlTextColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_disabledControlTextColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public void drawSwatchInRect (NSRect rect)
- {
- OS.objc_msgSend(this.id_, OS.sel_drawSwatchInRect_1, rect);
- }
-
- public void getComponents (CGFloat[] components)
- {
- OS.objc_msgSend(this.id_, OS.sel_getComponents_1, components);
- }
+public static NSColor controlShadowColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlShadowColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public void getCyan (CGFloat* cyan, CGFloat* magenta, CGFloat* yellow, CGFloat* black, CGFloat* alpha)
- {
- OS.objc_msgSend(this.id_, OS.sel_getCyan_1magenta_1yellow_1black_1alpha_1, cyan, magenta, yellow, black, alpha);
- }
-
- public void getHue (CGFloat* hue, CGFloat* saturation, CGFloat* brightness, CGFloat* alpha)
- {
- OS.objc_msgSend(this.id_, OS.sel_getHue_1saturation_1brightness_1alpha_1, hue, saturation, brightness, alpha);
- }
-
- public void getRed (CGFloat* red, CGFloat* green, CGFloat* blue, CGFloat* alpha)
- {
- OS.objc_msgSend(this.id_, OS.sel_getRed_1green_1blue_1alpha_1, red, green, blue, alpha);
- }
-
- public void getWhite (CGFloat* white, CGFloat* alpha)
- {
- OS.objc_msgSend(this.id_, OS.sel_getWhite_1alpha_1, white, alpha);
- }
-
- public static NSColor grayColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_grayColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor greenColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_greenColor);
- return result !is null ? new NSColor(result) : null;
- }
+public static NSColor controlTextColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlTextColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public CGFloat greenComponent ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_greenComponent);
- }
-
- public static NSColor gridColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_gridColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor headerColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_headerColor);
- return result !is null ? new NSColor(result) : null;
- }
+public static NSColor disabledControlTextColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_disabledControlTextColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public static NSColor headerTextColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_headerTextColor);
- return result !is null ? new NSColor(result) : null;
- }
+public void getComponents(float[] /*double[]*/ components) {
+ OS.objc_msgSend(this.id, OS.sel_getComponents_, components);
+}
- public static NSColor highlightColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_highlightColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public NSColor highlightWithLevel (CGFloat val)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_highlightWithLevel_1, val);
- return result is this.id_ ? this : (result !is null ? new NSColor(result) : null);
- }
-
- public CGFloat hueComponent ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_hueComponent);
- }
+public CGFloat greenComponent() {
+ return cast(CGFloat)OS.objc_msgSend_fpret(this.id, OS.sel_greenComponent);
+}
- public static bool ignoresAlpha ()
- {
- return OS.objc_msgSend(OS.class_NSColor, OS.sel_ignoresAlpha) !is null;
- }
-
- public static NSColor keyboardFocusIndicatorColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_keyboardFocusIndicatorColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor knobColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_knobColor);
- return result !is null ? new NSColor(result) : null;
- }
+public NSInteger numberOfComponents() {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfComponents);
+}
- public static NSColor lightGrayColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_lightGrayColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public NSString localizedCatalogNameComponent ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_localizedCatalogNameComponent);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString localizedColorNameComponent ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_localizedColorNameComponent);
- return result !is null ? new NSString(result) : null;
- }
+public CGFloat redComponent() {
+ return cast(CGFloat)OS.objc_msgSend_fpret(this.id, OS.sel_redComponent);
+}
- public static NSColor magentaColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_magentaColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public CGFloat magentaComponent ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_magentaComponent);
- }
-
- public NSInteger numberOfComponents ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfComponents);
- }
+public static NSColor secondarySelectedControlColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_secondarySelectedControlColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public static NSColor orangeColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_orangeColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public NSImage patternImage ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_patternImage);
- return result !is null ? new NSImage(result) : null;
- }
+public static NSColor selectedControlTextColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedControlTextColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public static NSColor purpleColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_purpleColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor redColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_redColor);
- return result !is null ? new NSColor(result) : null;
- }
+public static NSColor selectedTextBackgroundColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedTextBackgroundColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public CGFloat redComponent ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_redComponent);
- }
-
- public CGFloat saturationComponent ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_saturationComponent);
- }
-
- public static NSColor scrollBarColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_scrollBarColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor secondarySelectedControlColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_secondarySelectedControlColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor selectedControlColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedControlColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor selectedControlTextColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedControlTextColor);
- return result !is null ? new NSColor(result) : null;
- }
+public static NSColor selectedTextColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedTextColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public static NSColor selectedKnobColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedKnobColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor selectedMenuItemColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedMenuItemColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor selectedMenuItemTextColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedMenuItemTextColor);
- return result !is null ? new NSColor(result) : null;
- }
+public void set() {
+ OS.objc_msgSend(this.id, OS.sel_set);
+}
- public static NSColor selectedTextBackgroundColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedTextBackgroundColor);
- return result !is null ? new NSColor(result) : null;
- }
+public void setFill() {
+ OS.objc_msgSend(this.id, OS.sel_setFill);
+}
- public static NSColor selectedTextColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedTextColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public void set ()
- {
- OS.objc_msgSend(this.id_, OS.sel_set);
- }
-
- public void setFill ()
- {
- OS.objc_msgSend(this.id_, OS.sel_setFill);
- }
+public void setStroke() {
+ OS.objc_msgSend(this.id, OS.sel_setStroke);
+}
- public static void setIgnoresAlpha (bool flag)
- {
- OS.objc_msgSend(OS.class_NSColor, OS.sel_setIgnoresAlpha_1, flag);
- }
-
- public void setStroke ()
- {
- OS.objc_msgSend(this.id_, OS.sel_setStroke);
- }
-
- public static NSColor shadowColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_shadowColor);
- return result !is null ? new NSColor(result) : null;
- }
+public static NSColor textBackgroundColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_textBackgroundColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public NSColor shadowWithLevel (CGFloat val)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_shadowWithLevel_1, val);
- return result is this.id_ ? this : (result !is null ? new NSColor(result) : null);
- }
-
- public static NSColor textBackgroundColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_textBackgroundColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor textColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_textColor);
- return result !is null ? new NSColor(result) : null;
- }
+public static NSColor textColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_textColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public static NSColor whiteColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_whiteColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public CGFloat whiteComponent ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_whiteComponent);
- }
-
- public static NSColor windowBackgroundColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_windowBackgroundColor);
- return result !is null ? new NSColor(result) : null;
- }
+public static NSColor windowBackgroundColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_windowBackgroundColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public static NSColor windowFrameColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_windowFrameColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public static NSColor windowFrameTextColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_windowFrameTextColor);
- return result !is null ? new NSColor(result) : null;
- }
+public static NSColor windowFrameColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_windowFrameColor);
+ return result !is null ? new NSColor(result) : null;
+}
- public void writeToPasteboard (NSPasteboard pasteBoard)
- {
- OS.objc_msgSend(this.id_, OS.sel_writeToPasteboard_1, pasteBoard !is null ? pasteBoard.id_ : null);
- }
-
- public static NSColor yellowColor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_yellowColor);
- return result !is null ? new NSColor(result) : null;
- }
-
- public CGFloat yellowComponent ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_yellowComponent);
- }
+public static NSColor windowFrameTextColor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_windowFrameTextColor);
+ return result !is null ? new NSColor(result) : null;
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSColorList.d
--- a/dwt/internal/cocoa/NSColorList.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSColorList;
-
-import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSColor;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSColorList : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSArray allKeys ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_allKeys);
- return result !is null ? new NSArray(result) : null;
- }
-
- public static NSArray availableColorLists ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColorList, OS.sel_availableColorLists);
- return result !is null ? new NSArray(result) : null;
- }
-
- public static NSColorList colorListNamed (NSString name)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColorList, OS.sel_colorListNamed_1, name !is null ? name.id_ : null);
- return result !is null ? new NSColorList(result) : null;
- }
-
- public NSColor colorWithKey (NSString key)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_colorWithKey_1, key !is null ? key.id_ : null);
- return result !is null ? new NSColor(result) : null;
- }
-
- public NSColorList initWithName_ (NSString name)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithName_1, name !is null ? name.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSColorList initWithName_fromFile_ (NSString name, NSString path)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithName_1fromFile_1, name !is null ? name.id_ : null, path !is null ? path.id_ : null);
- return result !is null ? this : null;
- }
-
- public void insertColor (NSColor color, NSString key, NSUInteger loc)
- {
- OS.objc_msgSend(this.id_, OS.sel_insertColor_1key_1atIndex_1, color !is null ? color.id_ : null, key !is null ? key.id_ : null, loc);
- }
-
- public bool isEditable ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isEditable) !is null;
- }
-
- public NSString name ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_name);
- return result !is null ? new NSString(result) : null;
- }
-
- public void removeColorWithKey (NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeColorWithKey_1, key !is null ? key.id_ : null);
- }
-
- public void removeFile ()
- {
- OS.objc_msgSend(this.id_, OS.sel_removeFile);
- }
-
- public void setColor (NSColor color, NSString key)
- {
- OS.objc_msgSend(this.id_, OS.sel_setColor_1forKey_1, color !is null ? color.id_ : null, key !is null ? key.id_ : null);
- }
-
- public bool writeToFile (NSString path)
- {
- return OS.objc_msgSend(this.id_, OS.sel_writeToFile_1, path !is null ? path.id_ : null) !is null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSColorPanel.d
--- a/dwt/internal/cocoa/NSColorPanel.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSColorPanel.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,146 +1,51 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSColorPanel;
-import dwt.internal.cocoa.CGFloat;
-import dwt.internal.cocoa.id;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSColor;
-import dwt.internal.cocoa.NSColorList;
-import dwt.internal.cocoa.NSEvent;
-import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSPanel;
-import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
-alias NSInteger NSColorPanelMode;
-
-public class NSColorPanel : NSPanel
-{
-
- public this ()
- {
- super();
- }
+public class NSColorPanel : NSPanel {
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSView accessoryView ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_accessoryView);
- return result !is null ? new NSView(result) : null;
- }
-
- public CGFloat alpha ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_alpha);
- }
+public this() {
+ super();
+}
- public void attachColorList (NSColorList colorList)
- {
- OS.objc_msgSend(this.id_, OS.sel_attachColorList_1, colorList !is null ? colorList.id_ : null);
- }
-
- public NSColor color ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_color);
- return result !is null ? new NSColor(result) : null;
- }
-
- public void detachColorList (NSColorList colorList)
- {
- OS.objc_msgSend(this.id_, OS.sel_detachColorList_1, colorList !is null ? colorList.id_ : null);
- }
+public this(objc.id id) {
+ super(id);
+}
- public static bool dragColor (NSColor color, NSEvent theEvent, NSView sourceView)
- {
- return OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_dragColor_1withEvent_1fromView_1, color !is null ? color.id_ : null,
- theEvent !is null ? theEvent.id_ : null, sourceView !is null ? sourceView.id_ : null) !is null;
- }
-
- public bool isContinuous ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isContinuous) !is null;
- }
-
- public objc.id mode ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_mode);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public void setAccessoryView (NSView aView)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAccessoryView_1, aView !is null ? aView.id_ : null);
- }
-
- public void setAction (objc.SEL aSelector)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector);
- }
-
- public void setColor (NSColor color)
- {
- OS.objc_msgSend(this.id_, OS.sel_setColor_1, color !is null ? color.id_ : null);
- }
-
- public void setContinuous (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setContinuous_1, flag);
- }
-
- public void setMode (objc.id mode)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMode_1, mode);
- }
-
- public static void setPickerMask (NSUInteger mask)
- {
- OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_setPickerMask_1, mask);
- }
+public NSColor color() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_color);
+ return result !is null ? new NSColor(result) : null;
+}
- public static void setPickerMode (NSColorPanelMode mode)
- {
- OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_setPickerMode_1, mode);
- }
-
- public void setShowsAlpha (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setShowsAlpha_1, flag);
- }
-
- public void setTarget (id anObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTarget_1, anObject !is null ? anObject.id_ : null);
- }
+public void setColor(NSColor color) {
+ OS.objc_msgSend(this.id, OS.sel_setColor_, color !is null ? color.id : null);
+}
- public static NSColorPanel sharedColorPanel ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_sharedColorPanel);
- return result !is null ? new NSColorPanel(result) : null;
- }
-
- public static bool sharedColorPanelExists ()
- {
- return OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_sharedColorPanelExists) !is null;
- }
-
- public bool showsAlpha ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_showsAlpha) !is null;
- }
+public static NSColorPanel sharedColorPanel() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_sharedColorPanel);
+ return result !is null ? new NSColorPanel(result) : null;
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSColorPicker.d
--- a/dwt/internal/cocoa/NSColorPicker.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSColorPicker;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSButtonCell;
-import dwt.internal.cocoa.NSColorList;
-import dwt.internal.cocoa.NSColorPanel;
-import dwt.internal.cocoa.NSImage;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSSize;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSColorPicker : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public void attachColorList (NSColorList colorList)
- {
- OS.objc_msgSend(this.id_, OS.sel_attachColorList_1, colorList !is null ? colorList.id_ : null);
- }
-
- public NSString buttonToolTip ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_buttonToolTip);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSColorPanel colorPanel ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_colorPanel);
- return result !is null ? new NSColorPanel(result) : null;
- }
-
- public void detachColorList (NSColorList colorList)
- {
- OS.objc_msgSend(this.id_, OS.sel_detachColorList_1, colorList !is null ? colorList.id_ : null);
- }
-
- public NSColorPicker initWithPickerMask (NSUInteger mask, NSColorPanel owningColorPanel)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithPickerMask_1colorPanel_1, mask,
- owningColorPanel !is null ? owningColorPanel.id_ : null);
- return result !is null ? this : null;
- }
-
- public void insertNewButtonImage (NSImage newButtonImage, NSButtonCell buttonCell)
- {
- OS.objc_msgSend(this.id_, OS.sel_insertNewButtonImage_1in_1, newButtonImage !is null ? newButtonImage.id_ : null,
- buttonCell !is null ? buttonCell.id_ : null);
- }
-
- public NSSize minContentSize ()
- {
- NSSize result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_minContentSize);
- return result;
- }
-
- public NSImage provideNewButtonImage ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_provideNewButtonImage);
- return result !is null ? new NSImage(result) : null;
- }
-
- public void setMode (objc.id mode)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMode_1, mode);
- }
-
- public void viewSizeChanged (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_viewSizeChanged_1, sender !is null ? sender.id_ : null);
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSColorSpace.d
--- a/dwt/internal/cocoa/NSColorSpace.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSColorSpace.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,149 +1,42 @@
/*******************************************************************************
- * 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
*******************************************************************************/
+
module dwt.internal.cocoa.NSColorSpace;
-import dwt.internal.cocoa.CGColorSpace;
-import dwt.internal.cocoa.NSData;
-import dwt.internal.cocoa.NSInteger;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
-alias NSInteger NSColorSpaceModel;
+public class NSColorSpace : NSObject {
-enum
-{
- NSUnknownColorSpaceModel = -1,
- NSGrayColorSpaceModel,
- NSRGBColorSpaceModel,
- NSCMYKColorSpaceModel,
- NSLABColorSpaceModel,
- NSDeviceNColorSpaceModel,
- NSIndexedColorSpaceModel,
- NSPatternColorSpaceModel
+public this() {
+ super();
+}
+
+public this(objc.id id) {
+ super(id);
}
-public class NSColorSpace : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public objc.id CGColorSpace ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_CGColorSpace);
- }
-
- public NSData ICCProfileData ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_ICCProfileData);
- return result !is null ? new NSData(result) : null;
- }
-
- public static NSColorSpace adobeRGB1998ColorSpace ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_adobeRGB1998ColorSpace);
- return result !is null ? new NSColorSpace(result) : null;
- }
-
- public NSColorSpaceModel colorSpaceModel ()
- {
- return cast(NSColorSpaceModel) OS.objc_msgSend(this.id_, OS.sel_colorSpaceModel);
- }
-
- public void* colorSyncProfile ()
- {
- return cast(void*) OS.objc_msgSend(this.id_, OS.sel_colorSyncProfile);
- }
-
- public static NSColorSpace deviceCMYKColorSpace ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_deviceCMYKColorSpace);
- return result !is null ? new NSColorSpace(result) : null;
- }
-
- public static NSColorSpace deviceGrayColorSpace ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_deviceGrayColorSpace);
- return result !is null ? new NSColorSpace(result) : null;
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public static NSColorSpace deviceRGBColorSpace ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_deviceRGBColorSpace);
- return result !is null ? new NSColorSpace(result) : null;
- }
-
- public static NSColorSpace genericCMYKColorSpace ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_genericCMYKColorSpace);
- return result !is null ? new NSColorSpace(result) : null;
- }
-
- public static NSColorSpace genericGrayColorSpace ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_genericGrayColorSpace);
- return result !is null ? new NSColorSpace(result) : null;
- }
-
- public static NSColorSpace genericRGBColorSpace ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_genericRGBColorSpace);
- return result !is null ? new NSColorSpace(result) : null;
- }
-
- public NSColorSpace initWithCGColorSpace (CGColorSpaceRef cgColorSpace)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithCGColorSpace_1, cgColorSpace);
- return result !is null ? this : null;
- }
-
- public NSColorSpace initWithColorSyncProfile (void* prof)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithColorSyncProfile_1, prof);
- return result !is null ? this : null;
- }
-
- public NSColorSpace initWithICCProfileData (NSData iccData)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithICCProfileData_1, iccData !is null ? iccData.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSString localizedName ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_localizedName);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSInteger numberOfColorComponents ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfColorComponents);
- }
-
- public static NSColorSpace sRGBColorSpace ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_sRGBColorSpace);
- return result !is null ? new NSColorSpace(result) : null;
- }
+public static NSColorSpace deviceRGBColorSpace() {
+ objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_deviceRGBColorSpace);
+ return result !is null ? new NSColorSpace(result) : null;
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSColorWell.d
--- a/dwt/internal/cocoa/NSColorWell.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSColorWell;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSColor;
-import dwt.internal.cocoa.NSControl;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSRect;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSColorWell : NSControl
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public void activate (bool exclusive)
- {
- OS.objc_msgSend(this.id_, OS.sel_activate_1, exclusive);
- }
-
- public NSColor color ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_color);
- return result !is null ? new NSColor(result) : null;
- }
-
- public void deactivate ()
- {
- OS.objc_msgSend(this.id_, OS.sel_deactivate);
- }
-
- public void drawWellInside (NSRect insideRect)
- {
- OS.objc_msgSend(this.id_, OS.sel_drawWellInside_1, insideRect);
- }
-
- public bool isActive ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isActive) !is null;
- }
-
- public bool isBordered ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isBordered) !is null;
- }
-
- public void setBordered (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBordered_1, flag);
- }
-
- public void setColor (NSColor color)
- {
- OS.objc_msgSend(this.id_, OS.sel_setColor_1, color !is null ? color.id_ : null);
- }
-
- public void takeColorFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeColorFrom_1, sender !is null ? sender.id_ : null);
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSComboBox.d
--- a/dwt/internal/cocoa/NSComboBox.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSComboBox.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,219 +1,90 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSComboBox;
-import dwt.internal.cocoa.CGFloat;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSSize;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSTextField;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
-public class NSComboBox : NSTextField
-{
-
- public this ()
- {
- super();
- }
+public class NSComboBox : NSTextField {
- public this (objc.id id)
- {
- super(id);
- }
-
- public void addItemWithObjectValue (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_addItemWithObjectValue_1, object !is null ? object.id_ : null);
- }
+public this() {
+ super();
+}
- public void addItemsWithObjectValues (NSArray objects)
- {
- OS.objc_msgSend(this.id_, OS.sel_addItemsWithObjectValues_1, objects !is null ? objects.id_ : null);
- }
-
- public bool completes ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_completes) !is null;
- }
+public this(objc.id id) {
+ super(id);
+}
- public id dataSource ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_dataSource);
- return result !is null ? new id(result) : null;
- }
-
- public void deselectItemAtIndex (NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_deselectItemAtIndex_1, index);
- }
-
- public bool hasVerticalScroller ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_hasVerticalScroller) !is null;
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public NSInteger indexOfItemWithObjectValue (id object)
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemWithObjectValue_1, object !is null ? object.id_ : null);
- }
-
- public NSInteger indexOfSelectedItem ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfSelectedItem);
- }
+public void addItemWithObjectValue(cocoa.id object) {
+ OS.objc_msgSend(this.id, OS.sel_addItemWithObjectValue_, object !is null ? object.id : null);
+}
- public void insertItemWithObjectValue (id object, NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_insertItemWithObjectValue_1atIndex_1, object !is null ? object.id_ : null, index);
- }
-
- public NSSize intercellSpacing ()
- {
- NSSize result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_intercellSpacing);
- return result;
- }
+public void deselectItemAtIndex(NSInteger index) {
+ OS.objc_msgSend(this.id, OS.sel_deselectItemAtIndex_, index);
+}
- public bool isButtonBordered ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isButtonBordered) !is null;
- }
-
- public CGFloat itemHeight ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_itemHeight);
- }
+public NSInteger indexOfSelectedItem() {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfSelectedItem);
+}
- public objc.id itemObjectValueAtIndex (NSInteger index)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_itemObjectValueAtIndex_1, index);
- return result !is null ? result : null;
- }
-
- public void noteNumberOfItemsChanged ()
- {
- OS.objc_msgSend(this.id_, OS.sel_noteNumberOfItemsChanged);
- }
-
- public NSInteger numberOfItems ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfItems);
- }
-
- public NSInteger numberOfVisibleItems ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfVisibleItems);
- }
+public void insertItemWithObjectValue(cocoa.id object, NSInteger index) {
+ OS.objc_msgSend(this.id, OS.sel_insertItemWithObjectValue_atIndex_, object !is null ? object.id : null, index);
+}
- public id objectValueOfSelectedItem ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectValueOfSelectedItem);
- return result !is null ? new id(result) : null;
- }
-
- public NSArray objectValues ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectValues);
- return result !is null ? new NSArray(result) : null;
- }
-
- public void reloadData ()
- {
- OS.objc_msgSend(this.id_, OS.sel_reloadData);
- }
-
- public void removeAllItems ()
- {
- OS.objc_msgSend(this.id_, OS.sel_removeAllItems);
- }
+public cocoa.id itemObjectValueAtIndex(NSInteger index) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_itemObjectValueAtIndex_, index);
+ return result !is null ? new cocoa.id(result) : null;
+}
- public void removeItemAtIndex (NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeItemAtIndex_1, index);
- }
-
- public void removeItemWithObjectValue (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeItemWithObjectValue_1, object !is null ? object.id_ : null);
- }
+public NSInteger numberOfItems() {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfItems);
+}
- public void scrollItemAtIndexToTop (NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_scrollItemAtIndexToTop_1, index);
- }
+public NSInteger numberOfVisibleItems() {
+ return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfVisibleItems);
+}
- public void scrollItemAtIndexToVisible (NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_scrollItemAtIndexToVisible_1, index);
- }
-
- public void selectItemAtIndex (NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_selectItemAtIndex_1, index);
- }
+public void removeAllItems() {
+ OS.objc_msgSend(this.id, OS.sel_removeAllItems);
+}
- public void selectItemWithObjectValue (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_selectItemWithObjectValue_1, object !is null ? object.id_ : null);
- }
-
- public void setButtonBordered (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setButtonBordered_1, flag);
- }
+public void removeItemAtIndex(NSInteger index) {
+ OS.objc_msgSend(this.id, OS.sel_removeItemAtIndex_, index);
+}
- public void setCompletes (bool completes)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCompletes_1, completes);
- }
-
- public void setDataSource (id aSource)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDataSource_1, aSource !is null ? aSource.id_ : null);
- }
-
- public void setHasVerticalScroller (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setHasVerticalScroller_1, flag);
- }
+public void selectItemAtIndex(NSInteger index) {
+ OS.objc_msgSend(this.id, OS.sel_selectItemAtIndex_, index);
+}
- public void setIntercellSpacing (NSSize aSize)
- {
- OS.objc_msgSend(this.id_, OS.sel_setIntercellSpacing_1, aSize);
- }
-
- public void setItemHeight (CGFloat itemHeight)
- {
- OS.objc_msgSend(this.id_, OS.sel_setItemHeight_1, itemHeight);
- }
+public void setNumberOfVisibleItems(NSInteger visibleItems) {
+ OS.objc_msgSend(this.id, OS.sel_setNumberOfVisibleItems_, visibleItems);
+}
- public void setNumberOfVisibleItems (NSInteger visibleItems)
- {
- OS.objc_msgSend(this.id_, OS.sel_setNumberOfVisibleItems_1, visibleItems);
- }
+public static objc.Class cellClass() {
+ return cast(objc.Class) OS.objc_msgSend(OS.class_NSComboBox, OS.sel_cellClass);
+}
- public void setUsesDataSource (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setUsesDataSource_1, flag);
- }
-
- public bool usesDataSource ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_usesDataSource) !is null;
- }
+public static void setCellClass(objc.Class factoryId) {
+ OS.objc_msgSend(OS.class_NSComboBox, OS.sel_setCellClass_, factoryId);
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSComboBoxCell.d
--- a/dwt/internal/cocoa/NSComboBoxCell.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSComboBoxCell;
-
-import dwt.internal.cocoa.CGFloat;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSSize;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.NSTextFieldCell;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSComboBoxCell : NSTextFieldCell
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public void addItemWithObjectValue (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_addItemWithObjectValue_1, object !is null ? object.id_ : null);
- }
-
- public void addItemsWithObjectValues (NSArray objects)
- {
- OS.objc_msgSend(this.id_, OS.sel_addItemsWithObjectValues_1, objects !is null ? objects.id_ : null);
- }
-
- public NSString completedString (NSString string)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_completedString_1, string !is null ? string.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public bool completes ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_completes) !is null;
- }
-
- public id dataSource ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_dataSource);
- return result !is null ? new id(result) : null;
- }
-
- public void deselectItemAtIndex (NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_deselectItemAtIndex_1, index);
- }
-
- public bool hasVerticalScroller ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_hasVerticalScroller) !is null;
- }
-
- public NSInteger indexOfItemWithObjectValue (id object)
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemWithObjectValue_1, object !is null ? object.id_ : null);
- }
-
- public NSInteger indexOfSelectedItem ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfSelectedItem);
- }
-
- public void insertItemWithObjectValue (id object, NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_insertItemWithObjectValue_1atIndex_1, object !is null ? object.id_ : null, index);
- }
-
- public NSSize intercellSpacing ()
- {
- NSSize result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_intercellSpacing);
- return result;
- }
-
- public bool isButtonBordered ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isButtonBordered) !is null;
- }
-
- public CGFloat itemHeight ()
- {
- return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_itemHeight);
- }
-
- public id itemObjectValueAtIndex (NSInteger index)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_itemObjectValueAtIndex_1, index);
- return result !is null ? new id(result) : null;
- }
-
- public void noteNumberOfItemsChanged ()
- {
- OS.objc_msgSend(this.id_, OS.sel_noteNumberOfItemsChanged);
- }
-
- public NSInteger numberOfItems ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfItems);
- }
-
- public NSInteger numberOfVisibleItems ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfVisibleItems);
- }
-
- public id objectValueOfSelectedItem ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectValueOfSelectedItem);
- return result !is null ? new id(result) : null;
- }
-
- public NSArray objectValues ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectValues);
- return result !is null ? new NSArray(result) : null;
- }
-
- public void reloadData ()
- {
- OS.objc_msgSend(this.id_, OS.sel_reloadData);
- }
-
- public void removeAllItems ()
- {
- OS.objc_msgSend(this.id_, OS.sel_removeAllItems);
- }
-
- public void removeItemAtIndex (NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeItemAtIndex_1, index);
- }
-
- public void removeItemWithObjectValue (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeItemWithObjectValue_1, object !is null ? object.id_ : null);
- }
-
- public void scrollItemAtIndexToTop (NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_scrollItemAtIndexToTop_1, index);
- }
-
- public void scrollItemAtIndexToVisible (NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_scrollItemAtIndexToVisible_1, index);
- }
-
- public void selectItemAtIndex (NSInteger index)
- {
- OS.objc_msgSend(this.id_, OS.sel_selectItemAtIndex_1, index);
- }
-
- public void selectItemWithObjectValue (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_selectItemWithObjectValue_1, object !is null ? object.id_ : null);
- }
-
- public void setButtonBordered (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setButtonBordered_1, flag);
- }
-
- public void setCompletes (bool completes)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCompletes_1, completes);
- }
-
- public void setDataSource (id aSource)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDataSource_1, aSource !is null ? aSource.id_ : null);
- }
-
- public void setHasVerticalScroller (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setHasVerticalScroller_1, flag);
- }
-
- public void setIntercellSpacing (NSSize aSize)
- {
- OS.objc_msgSend(this.id_, OS.sel_setIntercellSpacing_1, aSize);
- }
-
- public void setItemHeight (CGFloat itemHeight)
- {
- OS.objc_msgSend(this.id_, OS.sel_setItemHeight_1, itemHeight);
- }
-
- public void setNumberOfVisibleItems (NSInteger visibleItems)
- {
- OS.objc_msgSend(this.id_, OS.sel_setNumberOfVisibleItems_1, visibleItems);
- }
-
- public void setUsesDataSource (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setUsesDataSource_1, flag);
- }
-
- public bool usesDataSource ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_usesDataSource) !is null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSComparisonPredicate.d
--- a/dwt/internal/cocoa/NSComparisonPredicate.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSComparisonPredicate;
-
-import dwt.internal.cocoa.NSExpression;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSPredicate;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-enum NSComparisonPredicateModifier
-{
- NSDirectPredicateModifier = 0,
- NSAllPredicateModifier,
- NSAnyPredicateModifier,
-}
-
-alias NSComparisonPredicateModifier.NSDirectPredicateModifier NSDirectPredicateModifier;
-alias NSComparisonPredicateModifier.NSAllPredicateModifier NSAllPredicateModifier;
-alias NSComparisonPredicateModifier.NSAnyPredicateModifier NSAnyPredicateModifier;
-
-public class NSComparisonPredicate : NSPredicate
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public objc.id comparisonPredicateModifier ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_comparisonPredicateModifier);
- }
-
- public objc.SEL customSelector ()
- {
- return cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_customSelector);
- }
-
- public NSComparisonPredicate initWithLeftExpression_rightExpression_customSelector_ (NSExpression lhs, NSExpression rhs, objc.SEL selector)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithLeftExpression_1rightExpression_1customSelector_1, lhs !is null ? lhs.id_ : null,
- rhs !is null ? rhs.id_ : null, selector);
- return result !is null ? this : null;
- }
-
- public NSComparisonPredicate initWithLeftExpression_rightExpression_modifier_type_options_ (NSExpression lhs, NSExpression rhs, objc.id modifier,
- objc.id type, NSUInteger options)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithLeftExpression_1rightExpression_1modifier_1type_1options_1,
- lhs !is null ? lhs.id_ : null, rhs !is null ? rhs.id_ : null, modifier, type, options);
- return result !is null ? this : null;
- }
-
- public NSExpression leftExpression ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_leftExpression);
- return result !is null ? new NSExpression(result) : null;
- }
-
- public NSUInteger options ()
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_options);
- }
-
- public objc.id predicateOperatorType ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_predicateOperatorType);
- }
-
- public static NSPredicate static_predicateWithLeftExpression_rightExpression_customSelector_ (NSExpression lhs, NSExpression rhs,
- objc.SEL selector)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSComparisonPredicate, OS.sel_predicateWithLeftExpression_1rightExpression_1customSelector_1,
- lhs !is null ? lhs.id_ : null, rhs !is null ? rhs.id_ : null, selector);
- return result !is null ? new NSPredicate(result) : null;
- }
-
- public static NSPredicate static_predicateWithLeftExpression_rightExpression_modifier_type_options_ (NSExpression lhs, NSExpression rhs,
- objc.id modifier, objc.id type, NSUInteger options)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSComparisonPredicate,
- OS.sel_predicateWithLeftExpression_1rightExpression_1modifier_1type_1options_1, lhs !is null ? lhs.id_ : null,
- rhs !is null ? rhs.id_ : null, modifier, type, options);
- return result !is null ? new NSPredicate(result) : null;
- }
-
- public NSExpression rightExpression ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_rightExpression);
- return result !is null ? new NSExpression(result) : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCompoundPredicate.d
--- a/dwt/internal/cocoa/NSCompoundPredicate.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * 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
- *******************************************************************************/
-module dwt.internal.cocoa.NSCompoundPredicate;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSPredicate;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSCompoundPredicate : NSPredicate
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public static NSPredicate andPredicateWithSubpredicates (NSArray subpredicates)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCompoundPredicate, OS.sel_andPredicateWithSubpredicates_1,
- subpredicates !is null ? subpredicates.id_ : null);
- return result !is null ? new NSPredicate(result) : null;
- }
-
- public objc.id compoundPredicateType ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_compoundPredicateType);
- }
-
- public id initWithType (objc.id type, NSArray subpredicates)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithType_1subpredicates_1, type, subpredicates !is null ? subpredicates.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static NSPredicate notPredicateWithSubpredicate (NSPredicate predicate)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCompoundPredicate, OS.sel_notPredicateWithSubpredicate_1,
- predicate !is null ? predicate.id_ : null);
- return result !is null ? new NSPredicate(result) : null;
- }
-
- public static NSPredicate orPredicateWithSubpredicates (NSArray subpredicates)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCompoundPredicate, OS.sel_orPredicateWithSubpredicates_1,
- subpredicates !is null ? subpredicates.id_ : null);
- return result !is null ? new NSPredicate(result) : null;
- }
-
- public NSArray subpredicates ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_subpredicates);
- return result !is null ? new NSArray(result) : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCondition.d
--- a/dwt/internal/cocoa/NSCondition.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSCondition;
-
-import dwt.internal.cocoa.NSDate;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSCondition : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public void broadcast ()
- {
- OS.objc_msgSend(this.id_, OS.sel_broadcast);
- }
-
- public NSString name ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_name);
- return result !is null ? new NSString(result) : null;
- }
-
- public void setName (NSString n)
- {
- OS.objc_msgSend(this.id_, OS.sel_setName_1, n !is null ? n.id_ : null);
- }
-
- public void signal ()
- {
- OS.objc_msgSend(this.id_, OS.sel_signal);
- }
-
- //public void wait() {
- // OS.objc_msgSend(this.id_, OS.sel_wait);
- //}
-
- public bool waitUntilDate (NSDate limit)
- {
- return OS.objc_msgSend(this.id_, OS.sel_waitUntilDate_1, limit !is null ? limit.id_ : null) !is null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSConditionLock.d
--- a/dwt/internal/cocoa/NSConditionLock.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSConditionLock;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSDate;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSConditionLock : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSInteger condition ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_condition);
- }
-
- public id initWithCondition (NSInteger condition)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithCondition_1, condition);
- return result !is null ? new id(result) : null;
- }
-
- public bool lockBeforeDate (NSDate limit)
- {
- return OS.objc_msgSend(this.id_, OS.sel_lockBeforeDate_1, limit !is null ? limit.id_ : null) !is null;
- }
-
- public void lockWhenCondition_ (NSInteger condition)
- {
- OS.objc_msgSend(this.id_, OS.sel_lockWhenCondition_1, condition);
- }
-
- public bool lockWhenCondition_beforeDate_ (NSInteger condition, NSDate limit)
- {
- return OS.objc_msgSend(this.id_, OS.sel_lockWhenCondition_1beforeDate_1, condition, limit !is null ? limit.id_ : null) !is null;
- }
-
- public NSString name ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_name);
- return result !is null ? new NSString(result) : null;
- }
-
- public void setName (NSString n)
- {
- OS.objc_msgSend(this.id_, OS.sel_setName_1, n !is null ? n.id_ : null);
- }
-
- public bool tryLock ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_tryLock) !is null;
- }
-
- public bool tryLockWhenCondition (NSInteger condition)
- {
- return OS.objc_msgSend(this.id_, OS.sel_tryLockWhenCondition_1, condition) !is null;
- }
-
- public void unlockWithCondition (NSInteger condition)
- {
- OS.objc_msgSend(this.id_, OS.sel_unlockWithCondition_1, condition);
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSConnection.d
--- a/dwt/internal/cocoa/NSConnection.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSConnection;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSConnection;
-import dwt.internal.cocoa.NSDictionary;
-import dwt.internal.cocoa.NSDistantObject;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSPort;
-import dwt.internal.cocoa.NSPortNameServer;
-import dwt.internal.cocoa.NSRunLoop;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSConnection : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public void addRequestMode (NSString rmode)
- {
- OS.objc_msgSend(this.id_, OS.sel_addRequestMode_1, rmode !is null ? rmode.id_ : null);
- }
-
- public void addRunLoop (NSRunLoop runloop)
- {
- OS.objc_msgSend(this.id_, OS.sel_addRunLoop_1, runloop !is null ? runloop.id_ : null);
- }
-
- public static NSArray allConnections ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_allConnections);
- return result !is null ? new NSArray(result) : null;
- }
-
- public static id connectionWithReceivePort (NSPort receivePort, NSPort sendPort)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_connectionWithReceivePort_1sendPort_1,
- receivePort !is null ? receivePort.id_ : null, sendPort !is null ? sendPort.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id static_connectionWithRegisteredName_host_ (NSString name, NSString hostName)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_connectionWithRegisteredName_1host_1, name !is null ? name.id_ : null,
- hostName !is null ? hostName.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id static_connectionWithRegisteredName_host_usingNameServer_ (NSString name, NSString hostName, NSPortNameServer server)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_connectionWithRegisteredName_1host_1usingNameServer_1,
- name !is null ? name.id_ : null, hostName !is null ? hostName.id_ : null, server !is null ? server.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id currentConversation ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_currentConversation);
- return result !is null ? new id(result) : null;
- }
-
- public static NSConnection defaultConnection ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_defaultConnection);
- return result !is null ? new NSConnection(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 void enableMultipleThreads ()
- {
- OS.objc_msgSend(this.id_, OS.sel_enableMultipleThreads);
- }
-
- public bool independentConversationQueueing ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_independentConversationQueueing) !is null;
- }
-
- public id initWithReceivePort (NSPort receivePort, NSPort sendPort)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithReceivePort_1sendPort_1, receivePort !is null ? receivePort.id_ : null,
- sendPort !is null ? sendPort.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public void invalidate ()
- {
- OS.objc_msgSend(this.id_, OS.sel_invalidate);
- }
-
- public bool isValid ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isValid) !is null;
- }
-
- public NSArray localObjects ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_localObjects);
- return result !is null ? new NSArray(result) : null;
- }
-
- public bool multipleThreadsEnabled ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_multipleThreadsEnabled) !is null;
- }
-
- public NSPort receivePort ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_receivePort);
- return result !is null ? new NSPort(result) : null;
- }
-
- public bool registerName_ (NSString name)
- {
- return OS.objc_msgSend(this.id_, OS.sel_registerName_1, name !is null ? name.id_ : null) !is null;
- }
-
- public bool registerName_withNameServer_ (NSString name, NSPortNameServer server)
- {
- return OS.objc_msgSend(this.id_, OS.sel_registerName_1withNameServer_1, name !is null ? name.id_ : null, server !is null ? server.id_ : null) !is null;
- }
-
- public NSArray remoteObjects ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_remoteObjects);
- return result !is null ? new NSArray(result) : null;
- }
-
- public void removeRequestMode (NSString rmode)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeRequestMode_1, rmode !is null ? rmode.id_ : null);
- }
-
- public void removeRunLoop (NSRunLoop runloop)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeRunLoop_1, runloop !is null ? runloop.id_ : null);
- }
-
- public double replyTimeout ()
- {
- return OS.objc_msgSend_fpret(this.id_, OS.sel_replyTimeout);
- }
-
- public NSArray requestModes ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_requestModes);
- return result !is null ? new NSArray(result) : null;
- }
-
- public double requestTimeout ()
- {
- return OS.objc_msgSend_fpret(this.id_, OS.sel_requestTimeout);
- }
-
- public id rootObject ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_rootObject);
- return result !is null ? new id(result) : null;
- }
-
- public NSDistantObject rootProxy ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_rootProxy);
- return result !is null ? new NSDistantObject(result) : null;
- }
-
- public static NSDistantObject static_rootProxyForConnectionWithRegisteredName_host_ (NSString name, NSString hostName)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_rootProxyForConnectionWithRegisteredName_1host_1,
- name !is null ? name.id_ : null, hostName !is null ? hostName.id_ : null);
- return result !is null ? new NSDistantObject(result) : null;
- }
-
- public static NSDistantObject static_rootProxyForConnectionWithRegisteredName_host_usingNameServer_ (NSString name, NSString hostName,
- NSPortNameServer server)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_rootProxyForConnectionWithRegisteredName_1host_1usingNameServer_1,
- name !is null ? name.id_ : null, hostName !is null ? hostName.id_ : null, server !is null ? server.id_ : null);
- return result !is null ? new NSDistantObject(result) : null;
- }
-
- public void runInNewThread ()
- {
- OS.objc_msgSend(this.id_, OS.sel_runInNewThread);
- }
-
- public NSPort sendPort ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_sendPort);
- return result !is null ? new NSPort(result) : null;
- }
-
- public static id static_serviceConnectionWithName_rootObject_ (NSString name, id root)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_serviceConnectionWithName_1rootObject_1, name !is null ? name.id_ : null,
- root !is null ? root.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id static_serviceConnectionWithName_rootObject_usingNameServer_ (NSString name, id root, NSPortNameServer server)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_serviceConnectionWithName_1rootObject_1usingNameServer_1,
- name !is null ? name.id_ : null, root !is null ? root.id_ : null, server !is null ? server.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public void setDelegate (id anObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, anObject !is null ? anObject.id_ : null);
- }
-
- public void setIndependentConversationQueueing (bool yorn)
- {
- OS.objc_msgSend(this.id_, OS.sel_setIndependentConversationQueueing_1, yorn);
- }
-
- public void setReplyTimeout (double ti)
- {
- OS.objc_msgSend(this.id_, OS.sel_setReplyTimeout_1, ti);
- }
-
- public void setRequestTimeout (double ti)
- {
- OS.objc_msgSend(this.id_, OS.sel_setRequestTimeout_1, ti);
- }
-
- public void setRootObject (id anObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_setRootObject_1, anObject !is null ? anObject.id_ : null);
- }
-
- public NSDictionary statistics ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_statistics);
- return result !is null ? new NSDictionary(result) : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSControl.d
--- a/dwt/internal/cocoa/NSControl.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSControl.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,372 +1,122 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSControl;
import dwt.dwthelper.utils;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSAttributedString;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSCell;
-import dwt.internal.cocoa.NSEvent;
import dwt.internal.cocoa.NSFont;
import dwt.internal.cocoa.NSFormatter;
-import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSText;
import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
-import obj = dwt.internal.objc.runtime;
-
-public class NSControl : NSView
-{
-
- public this ()
- {
- super();
- }
+import objc = dwt.internal.objc.runtime;
- public this (objc.id id)
- {
- super(id);
- }
-
- public bool abortEditing ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_abortEditing) !is null;
- }
+public class NSControl : NSView {
- public String action ()
- {
- return fromStringz(cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_action));
- }
-
- public objc.id alignment ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_alignment);
- }
-
- public NSAttributedString attributedStringValue ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedStringValue);
- return result !is null ? new NSAttributedString(result) : null;
- }
-
- public objc.id baseWritingDirection ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_baseWritingDirection);
- }
+public this() {
+ super();
+}
- public void calcSize ()
- {
- OS.objc_msgSend(this.id_, OS.sel_calcSize);
- }
-
- public objc.id cell ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_cell);
- return result !is null ? result : null;
- }
-
- public static objc.Class cellClass ()
- {
- return cast(objc.Class) OS.objc_msgSend(OS.class_NSControl, OS.sel_cellClass);
- }
+public this(objc.id id) {
+ super(id);
+}
- public NSText currentEditor ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_currentEditor);
- return result !is null ? new NSText(result) : null;
- }
-
- public double doubleValue ()
- {
- return OS.objc_msgSend_fpret(this.id_, OS.sel_doubleValue);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public void drawCell (NSCell aCell)
- {
- OS.objc_msgSend(this.id_, OS.sel_drawCell_1, aCell !is null ? aCell.id_ : null);
- }
-
- public void drawCellInside (NSCell aCell)
- {
- OS.objc_msgSend(this.id_, OS.sel_drawCellInside_1, aCell !is null ? aCell.id_ : null);
- }
-
- public float floatValue ()
- {
- return cast(float) OS.objc_msgSend_fpret(this.id_, OS.sel_floatValue);
- }
+public objc.SEL action() {
+ return cast(objc.SEL) OS.objc_msgSend(this.id, OS.sel_action);
+}
- public NSFont font ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_font);
- return result !is null ? new NSFont(result) : null;
- }
-
- public id formatter ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_formatter);
- return result !is null ? new id(result) : null;
- }
-
- public bool ignoresMultiClick ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_ignoresMultiClick) !is null;
- }
+public NSCell cell() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_cell);
+ return result !is null ? new NSCell(result) : null;
+}
- public int intValue ()
- {
- return cast(int) OS.objc_msgSend(this.id_, OS.sel_intValue);
- }
-
- public NSInteger integerValue ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_integerValue);
- }
-
- public bool isContinuous ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isContinuous) !is null;
- }
-
- public bool isEnabled ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isEnabled) !is null;
- }
-
- public void mouseDown (NSEvent theEvent)
- {
- OS.objc_msgSend(this.id_, OS.sel_mouseDown_1, theEvent !is null ? theEvent.id_ : null);
- }
+public static objc.Class cellClass() {
+ return cast(objc.Class) OS.objc_msgSend(OS.class_NSControl, OS.sel_cellClass);
+}
- public id objectValue ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectValue);
- return result !is null ? new id(result) : null;
- }
+public NSText currentEditor() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_currentEditor);
+ return result !is null ? new NSText(result) : null;
+}
- public void performClick (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_performClick_1, sender !is null ? sender.id_ : null);
- }
-
- public bool refusesFirstResponder ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_refusesFirstResponder) !is null;
- }
-
- public void selectCell (NSCell aCell)
- {
- OS.objc_msgSend(this.id_, OS.sel_selectCell_1, aCell !is null ? aCell.id_ : null);
- }
+public double doubleValue() {
+ return OS.objc_msgSend_fpret(this.id, OS.sel_doubleValue);
+}
- public id selectedCell ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedCell);
- return result !is null ? new id(result) : null;
- }
-
- public NSInteger selectedTag ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_selectedTag);
- }
+public NSFont font() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_font);
+ return result !is null ? new NSFont(result) : null;
+}
- public bool sendAction (String theAction, id theTarget)
- {
- return OS.objc_msgSend(this.id_, OS.sel_sendAction_1to_1, theAction.ptr, theTarget !is null ? theTarget.id_ : null) !is null;
- }
-
- public NSInteger sendActionOn (NSInteger mask)
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_sendActionOn_1, mask);
- }
-
- public void setAction (String aSelector)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector.ptr);
- }
+public bool sendAction(objc.SEL theAction, cocoa.id theTarget) {
+ return OS.objc_msgSend_bool(this.id, OS.sel_sendAction_to_, theAction, theTarget !is null ? theTarget.id : null);
+}
- public void setAlignment (objc.id mode)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAlignment_1, mode);
- }
-
- public void setAttributedStringValue (NSAttributedString obj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAttributedStringValue_1, obj !is null ? obj.id_ : null);
- }
-
- public void setBaseWritingDirection (objc.id writingDirection)
- {
- OS.objc_msgSend(this.id_, OS.sel_setBaseWritingDirection_1, writingDirection);
- }
-
- public void setCell (NSCell aCell)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCell_1, aCell !is null ? aCell.id_ : null);
- }
+public void setAction(objc.SEL aSelector) {
+ OS.objc_msgSend(this.id, OS.sel_setAction_, aSelector);
+}
- public static void setCellClass (objc.Class factoryId)
- {
- OS.objc_msgSend(OS.class_NSControl, OS.sel_setCellClass_1, factoryId);
- }
-
- public void setContinuous (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setContinuous_1, flag);
- }
+public void setAlignment(NSTextAlignment mode) {
+ OS.objc_msgSend(this.id, OS.sel_setAlignment_, mode);
+}
- public void setDoubleValue (double aDouble)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDoubleValue_1, aDouble);
- }
-
- public void setEnabled (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setEnabled_1, flag);
- }
+public static void setCellClass(objc.Class factoryId) {
+ OS.objc_msgSend(OS.class_NSControl, OS.sel_setCellClass_, factoryId);
+}
- public void setFloatValue (float aFloat)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFloatValue_1, aFloat);
- }
-
- public void setFloatingPointFormat (bool autoRange, NSUInteger leftDigits, NSUInteger rightDigits)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFloatingPointFormat_1left_1right_1, autoRange, leftDigits, rightDigits);
- }
-
- public void setFont (NSFont fontObj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFont_1, fontObj !is null ? fontObj.id_ : null);
- }
-
- public void setFormatter (NSFormatter newFormatter)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFormatter_1, newFormatter !is null ? newFormatter.id_ : null);
- }
+public void setDoubleValue(double aDouble) {
+ OS.objc_msgSend(this.id, OS.sel_setDoubleValue_, aDouble);
+}
- public void setIgnoresMultiClick (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setIgnoresMultiClick_1, flag);
- }
-
- public void setIntValue (int anInt)
- {
- OS.objc_msgSend(this.id_, OS.sel_setIntValue_1, anInt);
- }
+public void setEnabled(bool flag) {
+ OS.objc_msgSend(this.id, OS.sel_setEnabled_, flag);
+}
- public void setIntegerValue (NSInteger anInteger)
- {
- OS.objc_msgSend(this.id_, OS.sel_setIntegerValue_1, anInteger);
- }
-
- public void setNeedsDisplay ()
- {
- OS.objc_msgSend(this.id_, OS.sel_setNeedsDisplay);
- }
-
- public void setObjectValue (id obj)
- {
- OS.objc_msgSend(this.id_, OS.sel_setObjectValue_1, obj !is null ? obj.id_ : null);
- }
+public void setFont(NSFont fontObj) {
+ OS.objc_msgSend(this.id, OS.sel_setFont_, fontObj !is null ? fontObj.id : null);
+}
- public void setRefusesFirstResponder (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setRefusesFirstResponder_1, flag);
- }
-
- public void setStringValue (NSString aString)
- {
- OS.objc_msgSend(this.id_, OS.sel_setStringValue_1, aString !is null ? aString.id_ : null);
- }
-
- public void setTag (NSInteger anInt)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTag_1, anInt);
- }
-
- public void setTarget (id anObject)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTarget_1, anObject !is null ? anObject.id_ : null);
- }
+public void setFormatter(NSFormatter newFormatter) {
+ OS.objc_msgSend(this.id, OS.sel_setFormatter_, newFormatter !is null ? newFormatter.id : null);
+}
- public void sizeToFit ()
- {
- OS.objc_msgSend(this.id_, OS.sel_sizeToFit);
- }
+public void setStringValue(NSString aString) {
+ OS.objc_msgSend(this.id, OS.sel_setStringValue_, aString !is null ? aString.id : null);
+}
- public NSString stringValue ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_stringValue);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSInteger tag ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_tag);
- }
-
- public void takeDoubleValueFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeDoubleValueFrom_1, sender !is null ? sender.id_ : null);
- }
+public void setTarget(cocoa.id anObject) {
+ OS.objc_msgSend(this.id, OS.sel_setTarget_, anObject !is null ? anObject.id : null);
+}
- public void takeFloatValueFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeFloatValueFrom_1, sender !is null ? sender.id_ : null);
- }
-
- public void takeIntValueFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeIntValueFrom_1, sender !is null ? sender.id_ : null);
- }
-
- public void takeIntegerValueFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeIntegerValueFrom_1, sender !is null ? sender.id_ : null);
- }
-
- public void takeObjectValueFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeObjectValueFrom_1, sender !is null ? sender.id_ : null);
- }
+public void sizeToFit() {
+ OS.objc_msgSend(this.id, OS.sel_sizeToFit);
+}
- public void takeStringValueFrom (id sender)
- {
- OS.objc_msgSend(this.id_, OS.sel_takeStringValueFrom_1, sender !is null ? sender.id_ : null);
- }
-
- public id target ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_target);
- return result !is null ? new id(result) : null;
- }
+public NSString stringValue() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_stringValue);
+ return result !is null ? new NSString(result) : null;
+}
- public void updateCell (NSCell aCell)
- {
- OS.objc_msgSend(this.id_, OS.sel_updateCell_1, aCell !is null ? aCell.id_ : null);
- }
-
- public void updateCellInside (NSCell aCell)
- {
- OS.objc_msgSend(this.id_, OS.sel_updateCellInside_1, aCell !is null ? aCell.id_ : null);
- }
-
- public void validateEditing ()
- {
- OS.objc_msgSend(this.id_, OS.sel_validateEditing);
- }
+public cocoa.id target() {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_target);
+ return result !is null ? new id(result) : null;
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSController.d
--- a/dwt/internal/cocoa/NSController.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSController;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSController : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public bool commitEditing ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_commitEditing) !is null;
- }
-
- public void commitEditingWithDelegate (id delegatee, bool didCommitSelector, void* contextInfo)
- {
- OS.objc_msgSend(this.id_, OS.sel_commitEditingWithDelegate_1didCommitSelector_1contextInfo_1, delegatee !is null ? delegatee.id_ : null,
- didCommitSelector, contextInfo);
- }
-
- public void discardEditing ()
- {
- OS.objc_msgSend(this.id_, OS.sel_discardEditing);
- }
-
- public bool isEditing ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isEditing) !is null;
- }
-
- public void objectDidBeginEditing (id editor)
- {
- OS.objc_msgSend(this.id_, OS.sel_objectDidBeginEditing_1, editor !is null ? editor.id_ : null);
- }
-
- public void objectDidEndEditing (id editor)
- {
- OS.objc_msgSend(this.id_, OS.sel_objectDidEndEditing_1, editor !is null ? editor.id_ : null);
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCountedSet.d
--- a/dwt/internal/cocoa/NSCountedSet.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSCountedSet;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSEnumerator;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSMutableSet;
-import dwt.internal.cocoa.NSSet;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSCountedSet : NSMutableSet
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public void addObject (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_addObject_1, object !is null ? object.id_ : null);
- }
-
- public NSUInteger countForObject (id object)
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_countForObject_1, object !is null ? object.id_ : null);
- }
-
- public NSCountedSet initWithSet (NSSet set)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithSet_1, set !is null ? set.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSEnumerator objectEnumerator ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectEnumerator);
- return result !is null ? new NSEnumerator(result) : null;
- }
-
- public void removeObject (id object)
- {
- OS.objc_msgSend(this.id_, OS.sel_removeObject_1, object !is null ? object.id_ : null);
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCreateCommand.d
--- a/dwt/internal/cocoa/NSCreateCommand.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSCreateCommand;
-
-import dwt.internal.cocoa.NSDictionary;
-import dwt.internal.cocoa.NSScriptClassDescription;
-import dwt.internal.cocoa.NSScriptCommand;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSCreateCommand : NSScriptCommand
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSScriptClassDescription createClassDescription ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_createClassDescription);
- return result !is null ? new NSScriptClassDescription(result) : null;
- }
-
- public NSDictionary resolvedKeyDictionary ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_resolvedKeyDictionary);
- return result !is null ? new NSDictionary(result) : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCursor.d
--- a/dwt/internal/cocoa/NSCursor.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSCursor.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,212 +1,106 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSCursor;
-import dwt.internal.cocoa.NSColor;
-import dwt.internal.cocoa.NSEvent;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSImage;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSPoint;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
-public class NSCursor : NSObject
-{
-
- public this ()
- {
- super();
- }
+public class NSCursor : NSObject {
- public this (objc.id id)
- {
- super(id);
- }
+public this() {
+ super();
+}
- public static NSCursor IBeamCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_IBeamCursor);
- return result !is null ? new NSCursor(result) : null;
- }
+public this(objc.id id) {
+ super(id);
+}
- public static NSCursor arrowCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_arrowCursor);
- return result !is null ? new NSCursor(result) : null;
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public static NSCursor closedHandCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_closedHandCursor);
- return result !is null ? new NSCursor(result) : null;
- }
- public static NSCursor crosshairCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_crosshairCursor);
- return result !is null ? new NSCursor(result) : null;
- }
-
- public static NSCursor currentCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_currentCursor);
- return result !is null ? new NSCursor(result) : null;
- }
+public static NSCursor IBeamCursor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_IBeamCursor);
+ return result !is null ? new NSCursor(result) : null;
+}
- public static NSCursor disappearingItemCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_disappearingItemCursor);
- return result !is null ? new NSCursor(result) : null;
- }
+public static NSCursor arrowCursor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_arrowCursor);
+ return result !is null ? new NSCursor(result) : null;
+}
- public static void hide ()
- {
- OS.objc_msgSend(OS.class_NSCursor, OS.sel_hide);
- }
-
- public NSPoint hotSpot ()
- {
- NSPoint result;
- OS.objc_msgSend_stret(&result, this.id_, OS.sel_hotSpot);
- return result;
- }
+public static NSCursor crosshairCursor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_crosshairCursor);
+ return result !is null ? new NSCursor(result) : null;
+}
- public NSImage image ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_image);
- return result !is null ? new NSImage(result) : null;
- }
-
- public NSCursor initWithImage_foregroundColorHint_backgroundColorHint_hotSpot_ (NSImage newImage, NSColor fg, NSColor bg, NSPoint hotSpot)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithImage_1foregroundColorHint_1backgroundColorHint_1hotSpot_1,
- newImage !is null ? newImage.id_ : null, fg !is null ? fg.id_ : null, bg !is null ? bg.id_ : null, hotSpot);
- return result !is null ? this : null;
- }
+public NSCursor initWithImage(NSImage newImage, NSPoint aPoint) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithImage_hotSpot_, newImage !is null ? newImage.id : null, aPoint);
+ return result is this.id ? this : (result !is null ? new NSCursor(result) : null);
+}
- public NSCursor initWithImage_hotSpot_ (NSImage newImage, NSPoint aPoint)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithImage_1hotSpot_1, newImage !is null ? newImage.id_ : null, aPoint);
- return result !is null ? this : null;
- }
-
- public bool isSetOnMouseEntered ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isSetOnMouseEntered) !is null;
- }
-
- public bool isSetOnMouseExited ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isSetOnMouseExited) !is null;
- }
+public static NSCursor pointingHandCursor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_pointingHandCursor);
+ return result !is null ? new NSCursor(result) : null;
+}
- public void mouseEntered (NSEvent theEvent)
- {
- OS.objc_msgSend(this.id_, OS.sel_mouseEntered_1, theEvent !is null ? theEvent.id_ : null);
- }
-
- public void mouseExited (NSEvent theEvent)
- {
- OS.objc_msgSend(this.id_, OS.sel_mouseExited_1, theEvent !is null ? theEvent.id_ : null);
- }
+public static NSCursor resizeDownCursor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeDownCursor);
+ return result !is null ? new NSCursor(result) : null;
+}
- public static NSCursor openHandCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_openHandCursor);
- return result !is null ? new NSCursor(result) : null;
- }
-
- public static NSCursor pointingHandCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_pointingHandCursor);
- return result !is null ? new NSCursor(result) : null;
- }
+public static NSCursor resizeLeftCursor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeLeftCursor);
+ return result !is null ? new NSCursor(result) : null;
+}
- public void pop ()
- {
- OS.objc_msgSend(this.id_, OS.sel_pop);
- }
-
- public static void static_pop ()
- {
- OS.objc_msgSend(OS.class_NSCursor, OS.sel_pop);
- }
+public static NSCursor resizeLeftRightCursor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeLeftRightCursor);
+ return result !is null ? new NSCursor(result) : null;
+}
- public void push ()
- {
- OS.objc_msgSend(this.id_, OS.sel_push);
- }
-
- public static NSCursor resizeDownCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeDownCursor);
- return result !is null ? new NSCursor(result) : null;
- }
-
- public static NSCursor resizeLeftCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeLeftCursor);
- return result !is null ? new NSCursor(result) : null;
- }
+public static NSCursor resizeRightCursor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeRightCursor);
+ return result !is null ? new NSCursor(result) : null;
+}
- public static NSCursor resizeLeftRightCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeLeftRightCursor);
- return result !is null ? new NSCursor(result) : null;
- }
-
- public static NSCursor resizeRightCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeRightCursor);
- return result !is null ? new NSCursor(result) : null;
- }
+public static NSCursor resizeUpCursor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeUpCursor);
+ return result !is null ? new NSCursor(result) : null;
+}
- public static NSCursor resizeUpCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeUpCursor);
- return result !is null ? new NSCursor(result) : null;
- }
-
- public static NSCursor resizeUpDownCursor ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeUpDownCursor);
- return result !is null ? new NSCursor(result) : null;
- }
+public static NSCursor resizeUpDownCursor() {
+ objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeUpDownCursor);
+ return result !is null ? new NSCursor(result) : null;
+}
- public void set ()
- {
- OS.objc_msgSend(this.id_, OS.sel_set);
- }
-
- public static void setHiddenUntilMouseMoves (bool flag)
- {
- OS.objc_msgSend(OS.class_NSCursor, OS.sel_setHiddenUntilMouseMoves_1, flag);
- }
+public void set() {
+ OS.objc_msgSend(this.id, OS.sel_set);
+}
- public void setOnMouseEntered (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setOnMouseEntered_1, flag);
- }
+public static void setHiddenUntilMouseMoves(bool flag) {
+ OS.objc_msgSend(OS.class_NSCursor, OS.sel_setHiddenUntilMouseMoves_, flag);
+}
- public void setOnMouseExited (bool flag)
- {
- OS.objc_msgSend(this.id_, OS.sel_setOnMouseExited_1, flag);
- }
-
- public static void unhide ()
- {
- OS.objc_msgSend(OS.class_NSCursor, OS.sel_unhide);
- }
+public void setOnMouseEntered(bool flag) {
+ OS.objc_msgSend(this.id, OS.sel_setOnMouseEntered_, flag);
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSCustomImageRep.d
--- a/dwt/internal/cocoa/NSCustomImageRep.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSCustomImageRep;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSImageRep;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSCustomImageRep : NSImageRep
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public id delegatee ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate);
- return result !is null ? new id(result) : null;
- }
-
- public objc.SEL drawSelector ()
- {
- return cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_drawSelector);
- }
-
- public NSCustomImageRep initWithDrawSelector (char[] aMethod, id anObject)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithDrawSelector_1delegate_1, aMethod, anObject !is null ? anObject.id_ : null);
- return result !is null ? this : null;
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSData.d
--- a/dwt/internal/cocoa/NSData.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSData.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,218 +1,58 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSData;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSInteger;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSRange;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.NSURL;
import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
import objc = dwt.internal.objc.runtime;
-public class NSData : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public void* bytes ()
- {
- return cast(void*) OS.objc_msgSend(this.id_, OS.sel_bytes);
- }
-
- public static id data ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_data);
- return result !is null ? new id(result) : null;
- }
+public class NSData : NSObject {
- public static id dataWithBytes (/*const*/void* bytes, NSUInteger length)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytes_1length_1, bytes, length);
- return result !is null ? new id(result) : null;
- }
-
- public static id static_dataWithBytesNoCopy_length_ (void* bytes, NSUInteger length)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytesNoCopy_1length_1, bytes, length);
- return result !is null ? new id(result) : null;
- }
-
- public static id static_dataWithBytesNoCopy_length_freeWhenDone_ (void* bytes, NSUInteger length, bool b)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytesNoCopy_1length_1freeWhenDone_1, bytes, length, b);
- return result !is null ? new id(result) : null;
- }
-
- public static id static_dataWithContentsOfFile_ (NSString path)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfFile_1, path !is null ? path.id_ : null);
- return result !is null ? new id(result) : null;
- }
+public this() {
+ super();
+}
- public static id static_dataWithContentsOfFile_options_error_ (NSString path, NSUInteger readOptionsMask, objc.id** errorPtr)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfFile_1options_1error_1, path !is null ? path.id_ : null,
- readOptionsMask, errorPtr);
- return result !is null ? new id(result) : null;
- }
-
- public static id dataWithContentsOfMappedFile (NSString path)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfMappedFile_1, path !is null ? path.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id static_dataWithContentsOfURL_ (NSURL url)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfURL_1, url !is null ? url.id_ : null);
- return result !is null ? new id(result) : null;
- }
+public this(objc.id id) {
+ super(id);
+}
- public static id static_dataWithContentsOfURL_options_error_ (NSURL url, NSUInteger readOptionsMask, objc.id** errorPtr)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfURL_1options_1error_1, url !is null ? url.id_ : null,
- readOptionsMask, errorPtr);
- return result !is null ? new id(result) : null;
- }
-
- public static id dataWithData (NSData data)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithData_1, data !is null ? data.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public NSString description ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_description);
- return result !is null ? new NSString(result) : null;
- }
-
- public void getBytes_ (void* buffer)
- {
- OS.objc_msgSend(this.id_, OS.sel_getBytes_1, buffer);
- }
-
- public void getBytes_length_ (void* buffer, NSUInteger length)
- {
- OS.objc_msgSend(this.id_, OS.sel_getBytes_1length_1, buffer, length);
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public void getBytes_range_ (void* buffer, NSRange range)
- {
- OS.objc_msgSend(this.id_, OS.sel_getBytes_1range_1, buffer, range);
- }
-
- public NSData initWithBytes (void* bytes, NSUInteger length)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithBytes_1length_1, bytes, length);
- return result !is null ? this : null;
- }
-
- public NSData initWithBytesNoCopy_length_ (void* bytes, NSUInteger length)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithBytesNoCopy_1length_1, bytes, length);
- return result !is null ? this : null;
- }
-
- public NSData initWithBytesNoCopy_length_freeWhenDone_ (void* bytes, NSUInteger length, bool b)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithBytesNoCopy_1length_1freeWhenDone_1, bytes, length, b);
- return result !is null ? this : null;
- }
+public /*const*/void* bytes() {
+ return cast(/*const*/void*) OS.objc_msgSend(this.id, OS.sel_bytes);
+}
- public NSData initWithContentsOfFile_ (NSString path)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfFile_1, path !is null ? path.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSData initWithContentsOfFile_options_error_ (NSString path, NSUInteger readOptionsMask, objc.id** errorPtr)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfFile_1options_1error_1, path !is null ? path.id_ : null, readOptionsMask,
- errorPtr);
- return result !is null ? this : null;
- }
-
- public NSData initWithContentsOfMappedFile (NSString path)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfMappedFile_1, path !is null ? path.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSData initWithContentsOfURL_ (NSURL url)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfURL_1, url !is null ? url.id_ : null);
- return result !is null ? this : null;
- }
+public static NSData dataWithBytes(/*const*/void*, NSUInteger length) {
+ objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytes_length_, bytes, length);
+ return result !is null ? new NSData(result) : null;
+}
- public NSData initWithContentsOfURL_options_error_ (NSURL url, NSUInteger readOptionsMask, objc.id** errorPtr)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfURL_1options_1error_1, url !is null ? url.id_ : null, readOptionsMask,
- errorPtr);
- return result !is null ? this : null;
- }
-
- public NSData initWithData (NSData data)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithData_1, data !is null ? data.id_ : null);
- return result !is null ? this : null;
- }
-
- public bool isEqualToData (NSData other)
- {
- return OS.objc_msgSend(this.id_, OS.sel_isEqualToData_1, other !is null ? other.id_ : null) !is null;
- }
-
- public NSUInteger length ()
- {
- return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_length);
- }
+public void getBytes(void* buffer) {
+ OS.objc_msgSend(this.id, OS.sel_getBytes_, buffer);
+}
- public NSData subdataWithRange (NSRange range)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_subdataWithRange_1, range);
- return result is this.id_ ? this : (result !is null ? new NSData(result) : null);
- }
-
- public bool writeToFile_atomically_ (NSString path, bool useAuxiliaryFile)
- {
- return OS.objc_msgSend(this.id_, OS.sel_writeToFile_1atomically_1, path !is null ? path.id_ : null, useAuxiliaryFile) !is null;
- }
+public void getBytes(void* buffer, NSUInteger length) {
+ OS.objc_msgSend(this.id, OS.sel_getBytes_length_, buffer, length);
+}
- public bool writeToFile_options_error_ (NSString path, NSUInteger writeOptionsMask, objc.id** errorPtr)
- {
- return OS.objc_msgSend(this.id_, OS.sel_writeToFile_1options_1error_1, path !is null ? path.id_ : null, writeOptionsMask, errorPtr) !is null;
- }
-
- public bool writeToURL_atomically_ (NSURL url, bool atomically)
- {
- return OS.objc_msgSend(this.id_, OS.sel_writeToURL_1atomically_1, url !is null ? url.id_ : null, atomically) !is null;
- }
-
- public bool writeToURL_options_error_ (NSURL url, NSUInteger writeOptionsMask, objc.id** errorPtr)
- {
- return OS.objc_msgSend(this.id_, OS.sel_writeToURL_1options_1error_1, url !is null ? url.id_ : null, writeOptionsMask, errorPtr) !is null;
- }
+public NSUInteger length() {
+ return OS.objc_msgSend(this.id, OS.sel_length);
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSDate.d
--- a/dwt/internal/cocoa/NSDate.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSDate.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,19 +1,20 @@
/*******************************************************************************
- * 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
*******************************************************************************/
module dwt.internal.cocoa.NSDate;
-import dwt.internal.cocoa.id;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSCalendarDate;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSString;
@@ -23,175 +24,33 @@
alias double NSTimeInterval;
-public class NSDate : NSObject
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public id addTimeInterval (double seconds)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_addTimeInterval_1, seconds);
- return result !is null ? new id(result) : null;
- }
+public class NSDate : NSObject {
- public objc.id compare (NSDate other)
- {
- return OS.objc_msgSend(this.id_, OS.sel_compare_1, other !is null ? other.id_ : null);
- }
-
- public static NSDate date ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_date);
- return result !is null ? new NSDate(result) : null;
- }
-
- public NSCalendarDate dateWithCalendarFormat (NSString format, NSTimeZone aTimeZone)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_dateWithCalendarFormat_1timeZone_1, format !is null ? format.id_ : null,
- aTimeZone !is null ? aTimeZone.id_ : null);
- return result !is null ? new NSCalendarDate(result) : null;
- }
+public this() {
+ super();
+}
- public static id static_dateWithNaturalLanguageString_ (NSString string)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithNaturalLanguageString_1, string !is null ? string.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id static_dateWithNaturalLanguageString_locale_ (NSString string, id locale)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithNaturalLanguageString_1locale_1, string !is null ? string.id_ : null,
- locale !is null ? locale.id_ : null);
- return result !is null ? new id(result) : null;
- }
-
- public static id dateWithString (NSString aString)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithString_1, aString !is null ? aString.id_ : null);
- return result !is null ? new id(result) : null;
- }
+public this(objc.id id) {
+ super(id);
+}
- public static id dateWithTimeIntervalSince1970 (double secs)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithTimeIntervalSince1970_1, secs);
- return result !is null ? new id(result) : null;
- }
-
- public static NSDate dateWithTimeIntervalSinceNow (double secs)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithTimeIntervalSinceNow_1, secs);
- return result !is null ? new NSDate(result) : null;
- }
-
- public static id dateWithTimeIntervalSinceReferenceDate (double secs)
- {
- objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithTimeIntervalSinceReferenceDate_1, secs);
- return result !is null ? new id(result) : null;
- }
-
- public NSString description ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_description);
- return result !is null ? new NSString(result) : null;
- }
+public this(cocoa.id id) {
+ super(id);
+}
- public NSString descriptionWithCalendarFormat (NSString format, NSTimeZone aTimeZone, id locale)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithCalendarFormat_1timeZone_1locale_1, format !is null ? format.id_ : null,
- aTimeZone !is null ? aTimeZone.id_ : null, locale !is null ? locale.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString descriptionWithLocale (id locale)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public static NSDate distantFuture ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_distantFuture);
- return result !is null ? new NSDate(result) : null;
- }
-
- public static NSDate distantPast ()
- {
- objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_distantPast);
- return result !is null ? new NSDate(result) : null;
- }
-
- public NSDate earlierDate (NSDate anotherDate)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_earlierDate_1, anotherDate !is null ? anotherDate.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSDate(result) : null);
- }
-
- public NSDate initWithString (NSString description)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1, description !is null ? description.id_ : null);
- return result !is null ? this : null;
- }
-
- public NSDate initWithTimeInterval (double secsToBeAdded, NSDate anotherDate)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithTimeInterval_1sinceDate_1, secsToBeAdded,
- anotherDate !is null ? anotherDate.id_ : null);
- return result !is null ? this : null;
- }
+public NSCalendarDate dateWithCalendarFormat(NSString format, NSTimeZone aTimeZone) {
+ objc.id result = OS.objc_msgSend(this.id, OS.sel_dateWithCalendarFormat_timeZone_, format !is null ? format.id : null, aTimeZone !is null ? aTimeZone.id : null);
+ return result !is null ? new NSCalendarDate(result) : null;
+}
- public NSDate initWithTimeIntervalSinceNow (double secsToBeAddedToNow)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithTimeIntervalSinceNow_1, secsToBeAddedToNow);
- return result !is null ? this : null;
- }
-
- public NSDate initWithTimeIntervalSinceReferenceDate (double secsToBeAdded)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithTimeIntervalSinceReferenceDate_1, secsToBeAdded);
- return result !is null ? this : null;
- }
-
- public bool isEqualToDate (NSDate otherDate)
- {
- return OS.objc_msgSend(this.id_, OS.sel_isEqualToDate_1, otherDate !is null ? otherDate.id_ : null) !is null;
- }
-
- public NSDate laterDate (NSDate anotherDate)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_laterDate_1, anotherDate !is null ? anotherDate.id_ : null);
- return result is this.id_ ? this : (result !is null ? new NSDate(result) : null);
- }
+public static NSDate dateWithTimeIntervalSinceNow(double secs) {
+ objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithTimeIntervalSinceNow_, secs);
+ return result !is null ? new NSDate(result) : null;
+}
- public double timeIntervalSince1970 ()
- {
- return OS.objc_msgSend_fpret(this.id_, OS.sel_timeIntervalSince1970);
- }
-
- public double timeIntervalSinceDate (NSDate anotherDate)
- {
- return OS.objc_msgSend_fpret(this.id_, OS.sel_timeIntervalSinceDate_1, anotherDate !is null ? anotherDate.id_ : null);
- }
-
- public double timeIntervalSinceNow ()
- {
- return OS.objc_msgSend_fpret(this.id_, OS.sel_timeIntervalSinceNow);
- }
-
- public static double static_timeIntervalSinceReferenceDate ()
- {
- return OS.objc_msgSend_fpret(OS.class_NSDate, OS.sel_timeIntervalSinceReferenceDate);
- }
-
- public double timeIntervalSinceReferenceDate ()
- {
- return OS.objc_msgSend_fpret(this.id_, OS.sel_timeIntervalSinceReferenceDate);
- }
+public static NSDate distantFuture() {
+ objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_distantFuture);
+ return result !is null ? new NSDate(result) : null;
+}
}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSDateComponents.d
--- a/dwt/internal/cocoa/NSDateComponents.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSDateComponents;
-
-import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSDateComponents : NSObject
-{
-
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSInteger day ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_day);
- }
-
- public NSInteger era ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_era);
- }
-
- public NSInteger hour ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_hour);
- }
-
- public NSInteger minute ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_minute);
- }
-
- public NSInteger month ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_month);
- }
-
- public NSInteger second ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_second);
- }
-
- public void setDay (NSInteger v)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDay_1, v);
- }
-
- public void setEra (NSInteger v)
- {
- OS.objc_msgSend(this.id_, OS.sel_setEra_1, v);
- }
-
- public void setHour (NSInteger v)
- {
- OS.objc_msgSend(this.id_, OS.sel_setHour_1, v);
- }
-
- public void setMinute (NSInteger v)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMinute_1, v);
- }
-
- public void setMonth (NSInteger v)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMonth_1, v);
- }
-
- public void setSecond (NSInteger v)
- {
- OS.objc_msgSend(this.id_, OS.sel_setSecond_1, v);
- }
-
- public void setWeek (NSInteger v)
- {
- OS.objc_msgSend(this.id_, OS.sel_setWeek_1, v);
- }
-
- public void setWeekday (NSInteger v)
- {
- OS.objc_msgSend(this.id_, OS.sel_setWeekday_1, v);
- }
-
- public void setWeekdayOrdinal (NSInteger v)
- {
- OS.objc_msgSend(this.id_, OS.sel_setWeekdayOrdinal_1, v);
- }
-
- public void setYear (NSInteger v)
- {
- OS.objc_msgSend(this.id_, OS.sel_setYear_1, v);
- }
-
- public NSInteger week ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_week);
- }
-
- public NSInteger weekday ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_weekday);
- }
-
- public NSInteger weekdayOrdinal ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_weekdayOrdinal);
- }
-
- public NSInteger year ()
- {
- return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_year);
- }
-
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSDateFormatter.d
--- a/dwt/internal/cocoa/NSDateFormatter.d Tue Oct 21 15:20:04 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,424 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * Port to the D programming language:
- * Jacob Carlborg
- *******************************************************************************/
-module dwt.internal.cocoa.NSDateFormatter;
-
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSCalendar;
-import dwt.internal.cocoa.NSDate;
-import dwt.internal.cocoa.NSFormatter;
-import dwt.internal.cocoa.NSLocale;
-import dwt.internal.cocoa.NSRange;
-import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.NSTimeZone;
-import dwt.internal.cocoa.OS;
-import objc = dwt.internal.objc.runtime;
-
-public class NSDateFormatter : NSFormatter
-{
- public this ()
- {
- super();
- }
-
- public this (objc.id id)
- {
- super(id);
- }
-
- public NSString AMSymbol ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_AMSymbol);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSString PMSymbol ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_PMSymbol);
- return result !is null ? new NSString(result) : null;
- }
-
- public bool allowsNaturalLanguage ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_allowsNaturalLanguage) !is null;
- }
-
- public NSCalendar calendar ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_calendar);
- return result !is null ? new NSCalendar(result) : null;
- }
-
- public NSString dateFormat ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_dateFormat);
- return result !is null ? new NSString(result) : null;
- }
-
- public NSDate dateFromString (NSString string)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_dateFromString_1, string !is null ? string.id_ : null);
- return result !is null ? new NSDate(result) : null;
- }
-
- public objc.id dateStyle ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_dateStyle);
- }
-
- public NSDate defaultDate ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_defaultDate);
- return result !is null ? new NSDate(result) : null;
- }
-
- public static objc.id defaultFormatterBehavior ()
- {
- return OS.objc_msgSend(OS.class_NSDateFormatter, OS.sel_defaultFormatterBehavior);
- }
-
- public NSArray eraSymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_eraSymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public objc.id formatterBehavior ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_formatterBehavior);
- }
-
- public bool generatesCalendarDates ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_generatesCalendarDates) !is null;
- }
-
- public bool getObjectValue (objc.id* obj, NSString string, NSRange* rangep, objc.id** error)
- {
- return OS.objc_msgSend(this.id_, OS.sel_getObjectValue_1forString_1range_1error_1, obj, string !is null ? string.id_ : null, rangep, error) !is null;
- }
-
- public NSDate gregorianStartDate ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_gregorianStartDate);
- return result !is null ? new NSDate(result) : null;
- }
-
- public id initWithDateFormat (NSString format, bool flag)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithDateFormat_1allowNaturalLanguage_1, format !is null ? format.id_ : null, flag);
- return result !is null ? new id(result) : null;
- }
-
- public bool isLenient ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_isLenient) !is null;
- }
-
- public NSLocale locale ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_locale);
- return result !is null ? new NSLocale(result) : null;
- }
-
- public NSArray longEraSymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_longEraSymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray monthSymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_monthSymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray quarterSymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_quarterSymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public void setAMSymbol (NSString string)
- {
- OS.objc_msgSend(this.id_, OS.sel_setAMSymbol_1, string !is null ? string.id_ : null);
- }
-
- public void setCalendar (NSCalendar calendar)
- {
- OS.objc_msgSend(this.id_, OS.sel_setCalendar_1, calendar !is null ? calendar.id_ : null);
- }
-
- public void setDateFormat (NSString string)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDateFormat_1, string !is null ? string.id_ : null);
- }
-
- public void setDateStyle (objc.id style)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDateStyle_1, style);
- }
-
- public void setDefaultDate (NSDate date)
- {
- OS.objc_msgSend(this.id_, OS.sel_setDefaultDate_1, date !is null ? date.id_ : null);
- }
-
- public static void setDefaultFormatterBehavior (objc.id behavior)
- {
- OS.objc_msgSend(OS.class_NSDateFormatter, OS.sel_setDefaultFormatterBehavior_1, behavior);
- }
-
- public void setEraSymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setEraSymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setFormatterBehavior (objc.id behavior)
- {
- OS.objc_msgSend(this.id_, OS.sel_setFormatterBehavior_1, behavior);
- }
-
- public void setGeneratesCalendarDates (bool b)
- {
- OS.objc_msgSend(this.id_, OS.sel_setGeneratesCalendarDates_1, b);
- }
-
- public void setGregorianStartDate (NSDate date)
- {
- OS.objc_msgSend(this.id_, OS.sel_setGregorianStartDate_1, date !is null ? date.id_ : null);
- }
-
- public void setLenient (bool b)
- {
- OS.objc_msgSend(this.id_, OS.sel_setLenient_1, b);
- }
-
- public void setLocale (NSLocale locale)
- {
- OS.objc_msgSend(this.id_, OS.sel_setLocale_1, locale !is null ? locale.id_ : null);
- }
-
- public void setLongEraSymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setLongEraSymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setMonthSymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setMonthSymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setPMSymbol (NSString string)
- {
- OS.objc_msgSend(this.id_, OS.sel_setPMSymbol_1, string !is null ? string.id_ : null);
- }
-
- public void setQuarterSymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setQuarterSymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setShortMonthSymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setShortMonthSymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setShortQuarterSymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setShortQuarterSymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setShortStandaloneMonthSymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setShortStandaloneMonthSymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setShortStandaloneQuarterSymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setShortStandaloneQuarterSymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setShortStandaloneWeekdaySymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setShortStandaloneWeekdaySymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setShortWeekdaySymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setShortWeekdaySymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setStandaloneMonthSymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setStandaloneMonthSymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setStandaloneQuarterSymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setStandaloneQuarterSymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setStandaloneWeekdaySymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setStandaloneWeekdaySymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setTimeStyle (objc.id style)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTimeStyle_1, style);
- }
-
- public void setTimeZone (NSTimeZone tz)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTimeZone_1, tz !is null ? tz.id_ : null);
- }
-
- public void setTwoDigitStartDate (NSDate date)
- {
- OS.objc_msgSend(this.id_, OS.sel_setTwoDigitStartDate_1, date !is null ? date.id_ : null);
- }
-
- public void setVeryShortMonthSymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setVeryShortMonthSymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setVeryShortStandaloneMonthSymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setVeryShortStandaloneMonthSymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setVeryShortStandaloneWeekdaySymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setVeryShortStandaloneWeekdaySymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setVeryShortWeekdaySymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setVeryShortWeekdaySymbols_1, array !is null ? array.id_ : null);
- }
-
- public void setWeekdaySymbols (NSArray array)
- {
- OS.objc_msgSend(this.id_, OS.sel_setWeekdaySymbols_1, array !is null ? array.id_ : null);
- }
-
- public NSArray shortMonthSymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_shortMonthSymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray shortQuarterSymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_shortQuarterSymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray shortStandaloneMonthSymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_shortStandaloneMonthSymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray shortStandaloneQuarterSymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_shortStandaloneQuarterSymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray shortStandaloneWeekdaySymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_shortStandaloneWeekdaySymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray shortWeekdaySymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_shortWeekdaySymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray standaloneMonthSymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_standaloneMonthSymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray standaloneQuarterSymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_standaloneQuarterSymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray standaloneWeekdaySymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_standaloneWeekdaySymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSString stringFromDate (NSDate date)
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_stringFromDate_1, date !is null ? date.id_ : null);
- return result !is null ? new NSString(result) : null;
- }
-
- public objc.id timeStyle ()
- {
- return OS.objc_msgSend(this.id_, OS.sel_timeStyle);
- }
-
- public NSTimeZone timeZone ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_timeZone);
- return result !is null ? new NSTimeZone(result) : null;
- }
-
- public NSDate twoDigitStartDate ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_twoDigitStartDate);
- return result !is null ? new NSDate(result) : null;
- }
-
- public NSArray veryShortMonthSymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_veryShortMonthSymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray veryShortStandaloneMonthSymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_veryShortStandaloneMonthSymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray veryShortStandaloneWeekdaySymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_veryShortStandaloneWeekdaySymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray veryShortWeekdaySymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_veryShortWeekdaySymbols);
- return result !is null ? new NSArray(result) : null;
- }
-
- public NSArray weekdaySymbols ()
- {
- objc.id result = OS.objc_msgSend(this.id_, OS.sel_weekdaySymbols);
- return result !is null ? new NSArray(result) : null;
- }
-}
diff -r ca5e494f2bbf -r d8635bb48c7c dwt/internal/cocoa/NSDatePicker.d
--- a/dwt/internal/cocoa/NSDatePicker.d Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSDatePicker.d Mon Dec 01 17:07:00 2008 +0100
@@ -1,208 +1,93 @@
/*******************************************************************************
- * 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