# HG changeset patch # User Jacob Carlborg # Date 1230753673 -3600 # Node ID 2e671fa40eec043e88980eed751d42bf620e2881 # Parent e1c48e37e0f56caae7198ce704217f43a07a8d73 Ported dwt.dnd, dwt.opengl, dwt.printing and dwt.program diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/dnd/ByteArrayTransfer.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dnd/ByteArrayTransfer.d Wed Dec 31 21:01:13 2008 +0100 @@ -0,0 +1,192 @@ +/******************************************************************************* + * 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.dnd.ByteArrayTransfer; + +import dwt.dwthelper.utils; + +import dwt.internal.cocoa.NSData; + +import dwt.dnd.DND; +import dwt.dnd.Transfer; +import dwt.dnd.TransferData; + + +/** + * 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. + * + *

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 extends 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};
+ * }
+ * }
+ * 
+ * + * @see Transfer + */ +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. + * + * @param object a java byte[] containing the data 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 + */ +protected void javaToNative (Object object, TransferData transferData) { + if (!checkByteArray(object) && !isSupportedType(transferData)) { + DND.error(DND.ERROR_INVALID_DATA); + } + byte[] orig = (cast(ArrayWrapperByte)object).array; + NSData data = NSData.dataWithBytes(orig.ptr, orig.length); + transferData.data = data; +} + +/** + * This implementation of nativeToJava converts a platform specific + * representation of a byte array to a java byte[]. + * + * @param transferData the platform specific representation of the data to be converted + * @return a java byte[] containing the converted data if the conversion was + * successful; otherwise null + * + * @see Transfer#javaToNative + */ +protected Object nativeToJava(TransferData transferData) { + if (!isSupportedType(transferData) || transferData.data is null) return null; + if (transferData.data is null) return null; + NSData data = cast(NSData) transferData.data; + if (data.length() is 0) return null; + byte[] bytes = new byte[data.length()]; + data.getBytes(bytes.ptr); + return new ArrayWrapperByte(bytes); +} +bool checkByteArray(Object object) { + return (object !is null && cast(ArrayWrapperByte)object && (cast(ArrayWrapperByte)object).array.length > 0); +} +} diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/dnd/DragSource.d --- a/dwt/dnd/DragSource.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/dnd/DragSource.d Wed Dec 31 21:01:13 2008 +0100 @@ -186,7 +186,7 @@ // info for registering as a drag source Control control; Listener controlListener; - Transfer[] transferAgents = new Transfer[0]; + Transfer[] transferAgents; DragSourceEffect dragEffect; private int dragOperations; SWTDragSourceDelegate dragSourceDelegate; @@ -226,6 +226,8 @@ * @see DND#DROP_LINK */ public this(Control control, int style) { + transferAgents = new Transfer[0]; + super (control, checkStyle(style)); this.control = control; if (control.getData(DND.DRAG_SOURCE_KEY) !is null) { @@ -269,7 +271,7 @@ // access to this object's data. dragSourceDelegate = cast(SWTDragSourceDelegate)(new SWTDragSourceDelegate()).alloc().init(); delegateJniRef = OS.NewGlobalRef(this); - if (delegateJniRef is 0) DWT.error(DWT.ERROR_NO_HANDLES); + if (delegateJniRef is null) DWT.error(DWT.ERROR_NO_HANDLES); OS.object_setInstanceVariable(dragSourceDelegate.id, DWT_OBJECT, delegateJniRef); } @@ -457,7 +459,7 @@ return null; } -static objc.id dragSourceProc4(objc.id id, objc.id sel, objc.id arg0, objc.id arg1) { +static objc.id dragSourceProc4(objc.id id, objc.SEL sel, objc.id arg0, objc.id arg1) { Display display = Display.findDisplay(Thread.getThis()); if (display is null || display.isDisposed()) return null; Widget widget = display.findWidget(id); @@ -482,7 +484,7 @@ return null; } -static objc.id dragSourceProc5(objc.id id, objc.id sel, objc.id arg0, objc.id arg1, NSDragOperation arg2) { +static objc.id dragSourceProc5(objc.id id, objc.SEL sel, objc.id arg0, objc.id arg1, NSDragOperation arg2) { Display display = Display.findDisplay(Thread.getThis()); if (display is null || display.isDisposed()) return null; Widget widget = display.findWidget(id); @@ -548,7 +550,7 @@ } if (count is length_) return dragListeners; DragSourceListener[] result = new DragSourceListener[count]; - System.arraycopy(dragListeners, 0, result, 0, count); + SimpleType!(DragSourceListener).arraycopy(dragListeners, 0, result, 0, count); return result; } diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/dnd/DragSourceEvent.d --- a/dwt/dnd/DragSourceEvent.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/dnd/DragSourceEvent.d Wed Dec 31 21:01:13 2008 +0100 @@ -20,6 +20,7 @@ import dwt.dnd.DNDEvent; import dwt.dnd.TransferData; +import dwt.widgets.Event; /** * The DragSourceEvent contains the event information passed in the methods of the DragSourceListener. @@ -106,7 +107,7 @@ * @param e the untyped event containing the information */ public this(DNDEvent e) { - super(e); + super(cast(Event) e); this.data = e.data; this.detail = e.detail; this.doit = e.doit; diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/dnd/DropTarget.d --- a/dwt/dnd/DropTarget.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/dnd/DropTarget.d Wed Dec 31 21:01:13 2008 +0100 @@ -479,7 +479,7 @@ } if (count is length_) return dropListeners; DropTargetListener[] result = new DropTargetListener[count]; - System.arraycopy(dropListeners, 0, result, 0, count); + SimpleType!(DropTargetListener).arraycopy(dropListeners, 0, result, 0, count); return result; } @@ -839,7 +839,7 @@ NSMutableArray nsTypeStrings = NSMutableArray.arrayWithCapacity(typeStringCount); for (int i = 0; i < typeStringCount; i++) { - nsTypeStrings.addObject(NSString.stringWith(cast(String)typeStrings.get(i))); + nsTypeStrings.addObject(NSString.stringWith(typeStrings.get(i))); } control.view.registerForDraggedTypes(nsTypeStrings); diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/dnd/DropTargetEvent.d --- a/dwt/dnd/DropTargetEvent.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/dnd/DropTargetEvent.d Wed Dec 31 21:01:13 2008 +0100 @@ -20,6 +20,7 @@ import dwt.dnd.DNDEvent; import dwt.dnd.TransferData; +import dwt.widgets.Event; /** * The DropTargetEvent contains the event information passed in the methods of the DropTargetListener. @@ -98,7 +99,7 @@ * @param e the untyped event containing the information */ public this(DNDEvent e) { - super(e); + super(cast(Event) e); this.data = e.data; this.x = e.x; this.y = e.y; diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/dnd/Transfer.d --- a/dwt/dnd/Transfer.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/dnd/Transfer.d Wed Dec 31 21:01:13 2008 +0100 @@ -73,7 +73,7 @@ * @return the platform specific ids of the data types that can be converted using * this transfer agent */ -abstract protected int[] getTypeIds(); +abstract public int[] getTypeIds(); /** * Returns the platform specific names of the data types that can be converted @@ -82,7 +82,7 @@ * @return the platform specific names of the data types that can be converted * using this transfer agent. */ -abstract protected String[] getTypeNames(); +abstract public String[] getTypeNames(); /** * Converts a java representation of data to a platform specific representation of @@ -115,7 +115,7 @@ *
  • ERROR_INVALID_DATA - if object does not contain data in a valid format or is null
  • * */ -abstract protected void javaToNative (Object object, TransferData transferData); +abstract public void javaToNative (Object object, TransferData transferData); /** * Converts a platform specific representation of data to a java representation. @@ -128,7 +128,7 @@ * null is returned. The type of Object that is returned is * dependent on the Transfer subclass. */ -abstract protected Object nativeToJava(TransferData transferData); +abstract public Object nativeToJava(TransferData transferData); /** * Registers a name for a data type and returns the associated unique identifier. diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/dnd/URLTransfer.d --- a/dwt/dnd/URLTransfer.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/dnd/URLTransfer.d Wed Dec 31 21:01:13 2008 +0100 @@ -1,1 +1,116 @@ -/******************************************************************************* * 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 * * Port to the D programming language: * Jacob Carlborg *******************************************************************************/ module dwt.dnd.URLTransfer; import dwt.dwthelper.utils; import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.NSURL; import dwt.internal.cocoa.OS; import dwt.dnd.ByteArrayTransfer; import dwt.dnd.DND; import dwt.dnd.TransferData; /** * 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 : ByteArrayTransfer { static URLTransfer _instance; static final String URL; static final int URL_ID; static this () { _instance = new URLTransfer(); URL = OS.NSURLPboardType.getString(); URL_ID = registerType(URL); } private this() {} /** * 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 = (cast(ArrayWrapperString)object).array; 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 = cast(NSURL) transferData.data; NSString nsString = nsUrl.absoluteString(); return new ArrayWrapperString(nsString.getString()); } protected int[] getTypeIds(){ return [URL_ID]; } protected String[] getTypeNames(){ return [URL]; } bool checkURL(Object object) { return object !is null && (cast(ArrayWrapperString) object) && (cast(ArrayWrapperString) object).array.length() > 0; } protected bool validate(Object object) { return checkURL(object); } } \ No newline at end of file +/******************************************************************************* + * 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 + * + * Port to the D programming language: + * Jacob Carlborg + *******************************************************************************/ +module dwt.dnd.URLTransfer; + +import dwt.dwthelper.utils; + +import dwt.internal.cocoa.NSString; +import dwt.internal.cocoa.NSURL; +import dwt.internal.cocoa.OS; + +import dwt.dnd.ByteArrayTransfer; +import dwt.dnd.DND; +import dwt.dnd.TransferData; + +/** + * 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 : ByteArrayTransfer { + + static URLTransfer _instance; + static const String URL; + static const int URL_ID; + + static this () + { + _instance = new URLTransfer(); + URL = OS.NSURLPboardType.getString(); + URL_ID = registerType(URL); + } + +private this() {} + +/** + * 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 = (cast(ArrayWrapperString)object).array; + 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 = cast(NSURL) transferData.data; + NSString nsString = nsUrl.absoluteString(); + return new ArrayWrapperString(nsString.getString()); +} + +protected int[] getTypeIds(){ + return [URL_ID]; +} + +protected String[] getTypeNames(){ + return [URL]; +} + +bool checkURL(Object object) { + return object !is null && (cast(ArrayWrapperString) object) && (cast(ArrayWrapperString) object).array.length() > 0; +} + +protected bool validate(Object object) { + return checkURL(object); +} +} \ No newline at end of file diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/dwthelper/array.d --- a/dwt/dwthelper/array.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/dwthelper/array.d Wed Dec 31 21:01:13 2008 +0100 @@ -62,11 +62,11 @@ * Throws: AssertException if the length of the array is 0 * AssertException if the $(D_CODE index) is greater than the length of the array */ -T elementAt (T) (T[] arr, size_t index) +T elementAt (T) (T[] arr, int index) in { assert(arr.length > 0); - assert(index < arr.length); + assert(index > -1 && index < arr.length); } body { diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/dwthelper/utils.d Wed Dec 31 21:01:13 2008 +0100 @@ -34,6 +34,8 @@ import tango.text.UnicodeData; static import tango.util.collection.model.Seq; +static import dwt.dwthelper.array; + alias bool boolean; alias char[] String; alias tango.text.Text.Text!(char) StringBuffer; diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/internal/c/Carbon.d --- a/dwt/internal/c/Carbon.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/internal/c/Carbon.d Wed Dec 31 21:01:13 2008 +0100 @@ -106,7 +106,6 @@ alias ProcessSerialNumber * ProcessSerialNumberPtr; - // Appearance.h enum ThemeCursor : uint { @@ -219,28 +218,6 @@ -// CFString.h -enum CFStringEncoding // CFStringBuiltInEncodings -{ - kCFStringEncodingMacRoman = 0, - kCFStringEncodingWindowsLatin1 = 0x0500, - kCFStringEncodingISOLatin1 = 0x0201, - kCFStringEncodingNextStepLatin = 0x0B01, - kCFStringEncodingASCII = 0x0600, - kCFStringEncodingUnicode = 0x0100, - kCFStringEncodingUTF8 = 0x08000100, - kCFStringEncodingNonLossyASCII = 0x0BFF, - - kCFStringEncodingUTF16 = 0x0100, - kCFStringEncodingUTF16BE = 0x10000100, - kCFStringEncodingUTF16LE = 0x14000100, - kCFStringEncodingUTF32 = 0x0c000100, - kCFStringEncodingUTF32BE = 0x18000100, - kCFStringEncodingUTF32LE = 0x1c000100 -} - - - // CFURL.h alias bindings.CFURLCreateStringByAddingPercentEscapes CFURLCreateStringByAddingPercentEscapes; diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/internal/c/bindings.d --- a/dwt/internal/c/bindings.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/internal/c/bindings.d Wed Dec 31 21:01:13 2008 +0100 @@ -28,7 +28,7 @@ // CFURL.h -CFStringRef CFURLCreateStringByAddingPercentEscapes (CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding); +CFStringRef CFURLCreateStringByAddingPercentEscapes (CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, /*CFStringEncoding*/ size_t encoding); diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/internal/cocoa/NSOpenGL.d --- a/dwt/internal/cocoa/NSOpenGL.d Wed Dec 31 16:50:37 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/** - * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved. - * Authors: Jacob Carlborg - * Version: Initial created: Nov 28, 2008 - * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style) - * - */ -module dwt.internal.cocoa.NSOpenGL; - -enum NSOpenGLPixelFormatAttribute : uint -{ - NSOpenGLPFAAllRenderers = 1, - NSOpenGLPFADoubleBuffer = 5, - NSOpenGLPFAStereo = 6, - NSOpenGLPFAAuxBuffers = 7, - NSOpenGLPFAColorSize = 8, - NSOpenGLPFAAlphaSize = 11, - NSOpenGLPFADepthSize = 12, - NSOpenGLPFAStencilSize = 13, - NSOpenGLPFAAccumSize = 14, - NSOpenGLPFAMinimumPolicy = 51, - NSOpenGLPFAMaximumPolicy = 52, - NSOpenGLPFAOffScreen = 53, - NSOpenGLPFAFullScreen = 54, - NSOpenGLPFASampleBuffers = 55, - NSOpenGLPFASamples = 56, - NSOpenGLPFAAuxDepthStencil = 57, - NSOpenGLPFAColorFloat = 58, - NSOpenGLPFAMultisample = 59, - NSOpenGLPFASupersample = 60, - NSOpenGLPFASampleAlpha = 61, - NSOpenGLPFARendererID = 70, - NSOpenGLPFASingleRenderer = 71, - NSOpenGLPFANoRecovery = 72, - NSOpenGLPFAAccelerated = 73, - NSOpenGLPFAClosestPolicy = 74, - NSOpenGLPFARobust = 75, - NSOpenGLPFABackingStore = 76, - NSOpenGLPFAMPSafe = 78, - NSOpenGLPFAWindow = 80, - NSOpenGLPFAMultiScreen = 81, - NSOpenGLPFACompliant = 83, - NSOpenGLPFAScreenMask = 84, - NSOpenGLPFAPixelBuffer = 90, - NSOpenGLPFAAllowOfflineRenderers = 96, - NSOpenGLPFAVirtualScreenCount = 128 -} \ No newline at end of file diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/internal/cocoa/NSString.d --- a/dwt/internal/cocoa/NSString.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/internal/cocoa/NSString.d Wed Dec 31 21:01:13 2008 +0100 @@ -23,33 +23,6 @@ import dwt.internal.objc.cocoa.Cocoa; import objc = dwt.internal.objc.runtime; -enum NSStringEncoding : NSUInteger -{ - NSASCIIStringEncoding = 1, - NSNEXTSTEPStringEncoding = 2, - NSJapaneseEUCStringEncoding = 3, - NSUTF8StringEncoding = 4, - NSISOLatin1StringEncoding = 5, - NSSymbolStringEncoding = 6, - NSNonLossyASCIIStringEncoding = 7, - NSShiftJISStringEncoding = 8, - NSISOLatin2StringEncoding = 9, - NSUnicodeStringEncoding = 10, - NSWindowsCP1251StringEncoding = 11, - NSWindowsCP1252StringEncoding = 12, - NSWindowsCP1253StringEncoding = 13, - NSWindowsCP1254StringEncoding = 14, - NSWindowsCP1250StringEncoding = 15, - NSISO2022JPStringEncoding = 21, - NSMacOSRomanStringEncoding = 30, - NSUTF16BigEndianStringEncoding = 0x90000100, - NSUTF16LittleEndianStringEncoding = 0x94000100, - NSUTF32StringEncoding = 0x8c000100, - NSUTF32BigEndianStringEncoding = 0x98000100, - NSUTF32LittleEndianStringEncoding = 0x9c000100, - NSProprietaryStringEncoding = 65536 -} - public class NSString : NSObject { public this() { diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/internal/cocoa/NSWorkspace.d --- a/dwt/internal/cocoa/NSWorkspace.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/internal/cocoa/NSWorkspace.d Wed Dec 31 21:01:13 2008 +0100 @@ -84,7 +84,7 @@ return OS.objc_msgSend_bool(this.id, OS.sel_openURL_, url !is null ? url.id : null); } -public bool openURLs(NSArray urls, NSString bundleIdentifier, NSWorkspaceLaunchOptions options, NSAppleEventDescriptor descriptor, int /*long*/ identifiers) { +public bool openURLs(NSArray urls, NSString bundleIdentifier, NSWorkspaceLaunchOptions options, NSAppleEventDescriptor descriptor, objc.id* identifiers) { return OS.objc_msgSend_bool(this.id, OS.sel_openURLs_withAppBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifiers_, urls !is null ? urls.id : null, bundleIdentifier !is null ? bundleIdentifier.id : null, options, descriptor !is null ? descriptor.id : null, identifiers); } diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/internal/cocoa/OS.d --- a/dwt/internal/cocoa/OS.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/internal/cocoa/OS.d Wed Dec 31 21:01:13 2008 +0100 @@ -10,6 +10,26 @@ *******************************************************************************/ module dwt.internal.cocoa.OS; +// CFString.h +enum CFStringEncoding // CFStringBuiltInEncodings +{ + kCFStringEncodingMacRoman = 0, + kCFStringEncodingWindowsLatin1 = 0x0500, + kCFStringEncodingISOLatin1 = 0x0201, + kCFStringEncodingNextStepLatin = 0x0B01, + kCFStringEncodingASCII = 0x0600, + kCFStringEncodingUnicode = 0x0100, + kCFStringEncodingUTF8 = 0x08000100, + kCFStringEncodingNonLossyASCII = 0x0BFF, + + kCFStringEncodingUTF16 = 0x0100, + kCFStringEncodingUTF16BE = 0x10000100, + kCFStringEncodingUTF16LE = 0x14000100, + kCFStringEncodingUTF32 = 0x0c000100, + kCFStringEncodingUTF32BE = 0x18000100, + kCFStringEncodingUTF32LE = 0x1c000100 +} + // NSScroller.h enum NSScrollerPart { @@ -31,6 +51,35 @@ NSGrooveBorder = 3 } +enum NSSearchPathDirectory +{ +NSApplicationDirectory = 1, +NSDemoApplicationDirectory, +NSDeveloperApplicationDirectory, +NSAdminApplicationDirectory, +NSLibraryDirectory, +NSDeveloperDirectory, +NSUserDirectory, +NSDocumentationDirectory, +NSDocumentDirectory, +NSCoreServiceDirectory, +NSDesktopDirectory = 12, +NSCachesDirectory = 13, +NSApplicationSupportDirectory = 14, +NSDownloadsDirectory = 15, +NSAllApplicationsDirectory = 100, +NSAllLibrariesDirectory = 101 +} + +enum NSSearchPathDomainMask +{ +NSUserDomainMask = 1, +NSLocalDomainMask = 2, +NSNetworkDomainMask = 4, +NSSystemDomainMask = 8, +NSAllDomainsMask = 0x0ffff, +} + import dwt.dwthelper.utils; import dwt.internal.C; @@ -3626,12 +3675,12 @@ public static const int NSWritingDirectionRightToLeft = 1; alias NSDatePickerElementFlags.NSYearMonthDatePickerElementFlag NSYearMonthDatePickerElementFlag; alias NSDatePickerElementFlags.NSYearMonthDayDatePickerElementFlag NSYearMonthDayDatePickerElementFlag; -alias Carbon.CFStringEncoding.kCFStringEncodingUTF8 kCFStringEncodingUTF8; +alias CFStringEncoding.kCFStringEncodingUTF8 kCFStringEncodingUTF8; public static const int NSASCIIStringEncoding = 1; public static const int NSAdminApplicationDirectory = 4; public static const int NSAggregateExpressionType = 14; -alias Cocoa.NSSearchPathDirectory.NSAllApplicationsDirectory NSAllApplicationsDirectory; -alias Cocoa.NSSearchPathDomainMask.NSAllDomainsMask NSAllDomainsMask; +alias NSSearchPathDirectory.NSAllApplicationsDirectory NSAllApplicationsDirectory; +alias NSSearchPathDomainMask.NSAllDomainsMask NSAllDomainsMask; public static const int NSAllLibrariesDirectory = 101; public static const int NSAllPredicateModifier = 1; public static const int NSAnchoredSearch = 8; @@ -4048,7 +4097,7 @@ public static const int NSUTF32BigEndianStringEncoding = -1744830208; public static const int NSUTF32LittleEndianStringEncoding = -1677721344; public static const int NSUTF32StringEncoding = -1946156800; -alias NSStringEncoding.NSUTF8StringEncoding NSUTF8StringEncoding; +alias Cocoa.NSStringEncoding.NSUTF8StringEncoding NSUTF8StringEncoding; public static const int NSUncachedRead = 2; public static const int NSUndefinedDateComponent = 2147483647; public static const int NSUndoCloseGroupingRunLoopOrdering = 350000; diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/internal/objc/cocoa/Cocoa.d --- a/dwt/internal/objc/cocoa/Cocoa.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/internal/objc/cocoa/Cocoa.d Wed Dec 31 21:01:13 2008 +0100 @@ -147,36 +147,6 @@ } } -enum NSSearchPathDirectory -{ - NSApplicationDirectory = 1, - NSDemoApplicationDirectory, - NSDeveloperApplicationDirectory, - NSAdminApplicationDirectory, - NSLibraryDirectory, - NSDeveloperDirectory, - NSUserDirectory, - NSDocumentationDirectory, - NSDocumentDirectory, - NSCoreServiceDirectory, - NSDesktopDirectory = 12, - NSCachesDirectory = 13, - NSApplicationSupportDirectory = 14, - NSDownloadsDirectory = 15, - NSAllApplicationsDirectory = 100, - NSAllLibrariesDirectory = 101 -} - -enum NSSearchPathDomainMask -{ - NSUserDomainMask = 1, - NSLocalDomainMask = 2, - NSNetworkDomainMask = 4, - NSSystemDomainMask = 8, - NSAllDomainsMask = 0x0ffff, -} - - //NSAccessibility.h @@ -574,6 +544,37 @@ +// NSString.h + +enum NSStringEncoding : NSUInteger +{ + NSASCIIStringEncoding = 1, + NSNEXTSTEPStringEncoding = 2, + NSJapaneseEUCStringEncoding = 3, + NSUTF8StringEncoding = 4, + NSISOLatin1StringEncoding = 5, + NSSymbolStringEncoding = 6, + NSNonLossyASCIIStringEncoding = 7, + NSShiftJISStringEncoding = 8, + NSISOLatin2StringEncoding = 9, + NSUnicodeStringEncoding = 10, + NSWindowsCP1251StringEncoding = 11, + NSWindowsCP1252StringEncoding = 12, + NSWindowsCP1253StringEncoding = 13, + NSWindowsCP1254StringEncoding = 14, + NSWindowsCP1250StringEncoding = 15, + NSISO2022JPStringEncoding = 21, + NSMacOSRomanStringEncoding = 30, + NSUTF16BigEndianStringEncoding = 0x90000100, + NSUTF16LittleEndianStringEncoding = 0x94000100, + NSUTF32StringEncoding = 0x8c000100, + NSUTF32BigEndianStringEncoding = 0x98000100, + NSUTF32LittleEndianStringEncoding = 0x9c000100, + NSProprietaryStringEncoding = 65536 +} + + + // NSText.h enum NSTextAlignment { diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/internal/objc/cocoa/bindings.d --- a/dwt/internal/objc/cocoa/bindings.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/internal/objc/cocoa/bindings.d Wed Dec 31 21:01:13 2008 +0100 @@ -12,6 +12,7 @@ import dwt.internal.c.Carbon; import dwt.internal.cocoa.NSRect; import dwt.internal.objc.cocoa.Cocoa; +import dwt.internal.cocoa.OS; import dwt.internal.objc.runtime; alias c_long NSInteger; diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/printing/PrintDialog.d --- a/dwt/printing/PrintDialog.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/printing/PrintDialog.d Wed Dec 31 21:01:13 2008 +0100 @@ -69,7 +69,7 @@ * @see Widget#checkSubclass * @see Widget#getStyle */ -public this (Shell parent) { +public this (Shell parent) { this (parent, DWT.PRIMARY_MODAL); } @@ -101,7 +101,7 @@ * @see Widget#checkSubclass * @see Widget#getStyle */ -public this (Shell parent, int style) { +public this (Shell parent, int style) { super (parent, style); checkSubclass (); } diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/printing/PrinterData.d --- a/dwt/printing/PrinterData.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/printing/PrinterData.d Wed Dec 31 21:01:13 2008 +0100 @@ -113,20 +113,20 @@ * scope field value indicating that * all pages should be printed */ - public static final int ALL_PAGES = 0; + public static const int ALL_PAGES = 0; /** * scope field value indicating that * the range of pages specified by startPage and endPage * should be printed */ - public static final int PAGE_RANGE = 1; + public static const int PAGE_RANGE = 1; /** * scope field value indicating that * the current selection should be printed */ - public static final int SELECTION = 2; + public static const int SELECTION = 2; /** * private, platform-specific data diff -r e1c48e37e0f5 -r 2e671fa40eec dwt/program/Program.d --- a/dwt/program/Program.d Wed Dec 31 16:50:37 2008 +0100 +++ b/dwt/program/Program.d Wed Dec 31 21:01:13 2008 +0100 @@ -221,7 +221,7 @@ } } } - vector.dup; + return vector.dup; } finally { pool.release(); } @@ -245,8 +245,8 @@ NSAutoreleasePool pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init(); try { NSString unescapedStr = NSString.stringWith("%"); //$NON-NLS-1$ - if (fileName.indexOf(':') is -1) { - fileName = PREFIX_FILE + fileName; + if (dwt.dwthelper.utils.indexOf(fileName, ':') is -1) { + fileName = PREFIX_FILE ~ fileName; } else { String lowercaseName = fileName.toLowerCase (); if (lowercaseName.startsWith (PREFIX_HTTP) || lowercaseName.startsWith (PREFIX_HTTPS)) { @@ -254,8 +254,8 @@ } } NSString fullPath = NSString.stringWith(fileName); - CFStringRef ptr = OS.CFURLCreateStringByAddingPercentEscapes(null, fullPath.id, unescapedStr.id, null, OS.kCFStringEncodingUTF8); - NSString escapedString = new NSString(ptr); + CFStringRef ptr = OS.CFURLCreateStringByAddingPercentEscapes(null, cast(CFStringRef) fullPath.id, cast(CFStringRef) unescapedStr.id, null, OS.kCFStringEncodingUTF8); + NSString escapedString = new NSString(cast(objc.id)ptr); NSWorkspace workspace = NSWorkspace.sharedWorkspace(); bool result = workspace.openURL(NSURL.URLWithString(escapedString)); OS.CFRelease(ptr); @@ -284,7 +284,7 @@ try { NSWorkspace workspace = NSWorkspace.sharedWorkspace(); NSString fullPath = NSString.stringWith(fileName); - if (fileName.indexOf(':') is -1) { + if (dwt.dwthelper.utils.indexOf(fileName, ':') is -1) { return workspace.openFile(fullPath, NSString.stringWith(name)); } NSString unescapedStr = NSString.stringWith("%"); //$NON-NLS-1$ @@ -292,11 +292,11 @@ if (lowercaseName.startsWith (PREFIX_HTTP) || lowercaseName.startsWith (PREFIX_HTTPS)) { unescapedStr = NSString.stringWith("%#"); //$NON-NLS-1$ } - CFStringRef ptr = OS.CFURLCreateStringByAddingPercentEscapes(0, fullPath.id, unescapedStr.id, 0, OS.kCFStringEncodingUTF8); - NSString escapedString = new NSString(ptr); + CFStringRef ptr = OS.CFURLCreateStringByAddingPercentEscapes(null, cast(CFStringRef) fullPath.id, cast(CFStringRef) unescapedStr.id, null, OS.kCFStringEncodingUTF8); + NSString escapedString = new NSString(cast(objc.id) ptr); NSArray urls = NSArray.arrayWithObject(NSURL.URLWithString(escapedString)); OS.CFRelease(ptr); - return workspace.openURLs(urls, NSString.stringWith(identifier), 0, null, 0); + return workspace.openURLs(urls, NSString.stringWith(identifier), NSWorkspaceLaunchOptions.init, null, null); } finally { pool.release(); } @@ -327,7 +327,7 @@ nsImage.setSize(size); NSBitmapImageRep imageRep = null; NSImageRep rep = nsImage.bestRepresentationForDevice(null); - if (rep.isKindOfClass(OS.class_NSBitmapImageRep)) { + if (rep.isKindOfClass(cast(objc.Class) OS.class_NSBitmapImageRep)) { imageRep = new NSBitmapImageRep(rep.id); } if (imageRep !is null) { @@ -337,7 +337,7 @@ int bpp = cast(int)/*64*/imageRep.bitsPerPixel(); int dataSize = height * bpr; byte[] srcData = new byte[dataSize]; - OS.memmove(srcData, imageRep.bitmapData(), dataSize); + OS.memmove(srcData.ptr, imageRep.bitmapData(), dataSize); //TODO check color info PaletteData palette = new PaletteData(0xFF000000, 0xFF0000, 0xFF00); ImageData data = new ImageData(width, height, bpp, palette, 4, srcData); @@ -382,7 +382,7 @@ if (this is other) return true; if (cast(Program) other) { final Program program = cast(Program) other; - return name.equals(program.name); + return name == program.name; } return false; }