changeset 20:55c4568a2bab

Cursor
author Frank Benoit <benoit@tionex.de>
date Mon, 07 Jan 2008 08:07:46 +0100
parents b73b14942338
children 4f9c0fea3440
files dwt/dwthelper/Runnable.d dwt/graphics/Cursor.d dwt/internal/cairo/Cairo.d dwt/internal/gtk/OS.d dwt/internal/gtk/c/gdk.d
diffstat 5 files changed, 370 insertions(+), 76 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/Runnable.d	Mon Jan 07 08:07:46 2008 +0100
@@ -0,0 +1,9 @@
+module dwt.dwthelper.Runnable;
+
+public interface Runnable  {
+
+    public abstract void run();
+
+}
+
+
--- a/dwt/graphics/Cursor.d	Mon Jan 07 07:47:32 2008 +0100
+++ b/dwt/graphics/Cursor.d	Mon Jan 07 08:07:46 2008 +0100
@@ -10,12 +10,19 @@
  *******************************************************************************/
 module dwt.graphics.Cursor;
 
-class Cursor {
-}
 
-/++++
-import dwt.*;
-import dwt.internal.gtk.*;
+import dwt.SWT;
+import dwt.graphics.Resource;
+import dwt.graphics.Device;
+import dwt.graphics.ImageData;
+import dwt.graphics.RGB;
+import dwt.graphics.PaletteData;
+
+import dwt.internal.gtk.OS;
+import dwt.internal.gtk.c.gdktypes;
+
+import tango.text.convert.Format;
+import tango.stdc.string;
 
 /**
  * Instances of this class manage operating system resources that
@@ -41,7 +48,7 @@
  * Note: Only one of the above styles may be specified.
  * </p>
  */
-public final class Cursor extends Resource {
+public final class Cursor : Resource {
 	/**
 	 * the handle to the OS cursor resource
 	 * (Warning: This field is platform dependent)
@@ -52,35 +59,35 @@
 	 * platforms and should never be accessed from application code.
 	 * </p>
 	 */
-	public int /*long*/ handle;
+	public GdkCursor* handle;
 
-	static final byte[] APPSTARTING_SRC = {
+	static const byte[] APPSTARTING_SRC = [ cast(byte)
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
 		0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
-		0x7c, 0x00, 0x00, 0x00, (byte)0xfc, 0x00, 0x00, 0x00, (byte)0xfc, 0x01, 0x00, 0x00,
-		(byte)0xfc, 0x3b, 0x00, 0x00, 0x7c, 0x38, 0x00, 0x00, 0x6c, 0x54, 0x00, 0x00,
-		(byte)0xc4, (byte)0xdc, 0x00, 0x00, (byte)0xc0, 0x44, 0x00, 0x00, (byte)0x80, 0x39, 0x00, 0x00,
-		(byte)0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x7c, 0x00, 0x00, 0x00, cast(byte)0xfc, 0x00, 0x00, 0x00, cast(byte)0xfc, 0x01, 0x00, 0x00,
+		cast(byte)0xfc, 0x3b, 0x00, 0x00, 0x7c, 0x38, 0x00, 0x00, 0x6c, 0x54, 0x00, 0x00,
+		cast(byte)0xc4, cast(byte)0xdc, 0x00, 0x00, cast(byte)0xc0, 0x44, 0x00, 0x00, cast(byte)0x80, 0x39, 0x00, 0x00,
+		cast(byte)0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
 
-	static final byte[] APPSTARTING_MASK = {
+	static const byte[] APPSTARTING_MASK = [ cast(byte)
 		0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
 		0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
-		(byte)0xfe, 0x00, 0x00, 0x00, (byte)0xfe, 0x01, 0x00, 0x00, (byte)0xfe, 0x3b, 0x00, 0x00,
-		(byte)0xfe, 0x7f, 0x00, 0x00, (byte)0xfe, 0x7f, 0x00, 0x00, (byte)0xfe, (byte)0xfe, 0x00, 0x00,
-		(byte)0xee, (byte)0xff, 0x01, 0x00, (byte)0xe4, (byte)0xff, 0x00, 0x00, (byte)0xc0, 0x7f, 0x00, 0x00,
-		(byte)0xc0, 0x7f, 0x00, 0x00, (byte)0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		cast(byte)0xfe, 0x00, 0x00, 0x00, cast(byte)0xfe, 0x01, 0x00, 0x00, cast(byte)0xfe, 0x3b, 0x00, 0x00,
+		cast(byte)0xfe, 0x7f, 0x00, 0x00, cast(byte)0xfe, 0x7f, 0x00, 0x00, cast(byte)0xfe, cast(byte)0xfe, 0x00, 0x00,
+		cast(byte)0xee, cast(byte)0xff, 0x01, 0x00, cast(byte)0xe4, cast(byte)0xff, 0x00, 0x00, cast(byte)0xc0, 0x7f, 0x00, 0x00,
+		cast(byte)0xc0, 0x7f, 0x00, 0x00, cast(byte)0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
 
-Cursor () {
+this () {
 }
 
 /**
@@ -124,7 +131,7 @@
  * @see SWT#CURSOR_NO
  * @see SWT#CURSOR_HAND
  */
-public Cursor(Device device, int style) {
+public this(Device device, int style) {
 	if (device == null) device = Device.getDevice();
 	if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
 	this.device = device;
@@ -158,9 +165,9 @@
 	if (shape == 0 && style == SWT.CURSOR_APPSTARTING) {
 		handle = createCursor(APPSTARTING_SRC, APPSTARTING_MASK, 32, 32, 2, 2, true);
 	} else {
-		handle = OS.gdk_cursor_new(shape);
+		handle = OS.gdk_cursor_new(cast(GdkCursorType)shape);
 	}
-	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	if (handle is null) SWT.error(SWT.ERROR_NO_HANDLES);
 	if (device.tracking) device.new_Object(this);
 }
 
@@ -195,7 +202,7 @@
  *    <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
  * </ul>
  */
-public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
+public this(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
 	if (device == null) device = Device.getDevice();
 	if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
 	this.device = device;
@@ -223,7 +230,7 @@
 	byte[] data = source.data;
 	for (int i = 0; i < data.length; i++) {
 		byte s = data[i];
-		sourceData[i] = (byte)(((s & 0x80) >> 7) |
+		sourceData[i] = cast(byte)(((s & 0x80) >> 7) |
 			((s & 0x40) >> 5) |
 			((s & 0x20) >> 3) |
 			((s & 0x10) >> 1) |
@@ -231,13 +238,13 @@
 			((s & 0x04) << 3) |
 			((s & 0x02) << 5) |
 			((s & 0x01) << 7));
-		sourceData[i] = (byte) ~sourceData[i];
+		sourceData[i] = cast(byte) ~sourceData[i];
 	}
 	sourceData = ImageData.convertPad(sourceData, source.width, source.height, source.depth, source.scanlinePad, 1);
 	data = mask.data;
 	for (int i = 0; i < data.length; i++) {
 		byte s = data[i];
-		maskData[i] = (byte)(((s & 0x80) >> 7) |
+		maskData[i] = cast(byte)(((s & 0x80) >> 7) |
 			((s & 0x40) >> 5) |
 			((s & 0x20) >> 3) |
 			((s & 0x10) >> 1) |
@@ -245,11 +252,11 @@
 			((s & 0x04) << 3) |
 			((s & 0x02) << 5) |
 			((s & 0x01) << 7));
-		maskData[i] = (byte) ~maskData[i];
+		maskData[i] = cast(byte) ~maskData[i];
 	}
 	maskData = ImageData.convertPad(maskData, mask.width, mask.height, mask.depth, mask.scanlinePad, 1);
 	handle = createCursor(maskData, sourceData, source.width, source.height, hotspotX, hotspotY, true);
-	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	if (handle is null) SWT.error(SWT.ERROR_NO_HANDLES);
 	if (device.tracking) device.new_Object(this);
 }
 
@@ -280,7 +287,7 @@
  *
  * @since 3.0
  */
-public Cursor(Device device, ImageData source, int hotspotX, int hotspotY) {
+public this(Device device, ImageData source, int hotspotX, int hotspotY) {
 	if (device == null) device = Device.getDevice();
 	if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
 	this.device = device;
@@ -289,15 +296,15 @@
 		hotspotY >= source.height || hotspotY < 0) {
 		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
 	}
-	int /*long*/ display = 0;
-	if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0) && OS.gdk_display_supports_cursor_color(display = OS.gdk_display_get_default ())) {
+	GdkDisplay* display;
+	if (OS.GTK_VERSION >= OS.buildVERSION(2, 4, 0) && OS.gdk_display_supports_cursor_color(display = OS.gdk_display_get_default ())) {
 		int width = source.width;
 		int height = source.height;
 		PaletteData palette = source.palette;
-		int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, width, height);
-		if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		auto pixbuf = OS.gdk_pixbuf_new(cast(GdkColorspace)OS.GDK_COLORSPACE_RGB, true, 8, width, height);
+		if (pixbuf is null) SWT.error(SWT.ERROR_NO_HANDLES);
 		int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
-		int /*long*/ data = OS.gdk_pixbuf_get_pixels(pixbuf);
+		auto data = OS.gdk_pixbuf_get_pixels(pixbuf);
 		byte[] buffer = source.data;
 		if (!palette.isDirect || source.depth != 24 || stride != source.bytesPerLine || palette.redMask != 0xFF000000 || palette.greenMask != 0xFF0000 || palette.blueMask != 0xFF00) {
 			buffer = new byte[source.width * source.height * 4];
@@ -316,9 +323,9 @@
 				for (int i = 0; i < rgbs.length; i++) {
 					RGB rgb = rgbs[i];
 					if (rgb == null) continue;
-					srcReds[i] = (byte)rgb.red;
-					srcGreens[i] = (byte)rgb.green;
-					srcBlues[i] = (byte)rgb.blue;
+					srcReds[i] = cast(byte)rgb.red;
+					srcGreens[i] = cast(byte)rgb.green;
+					srcBlues[i] = cast(byte)rgb.blue;
 				}
 				ImageData.blit(ImageData.BLIT_SRC,
 					source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, srcReds, srcGreens, srcBlues,
@@ -333,13 +340,13 @@
 				int offset = 3, maskOffset = 0;
 				for (int y = 0; y<source.height; y++) {
 					for (int x = 0; x<source.width; x++) {
-						buffer[offset] = ((maskData[maskOffset + (x >> 3)]) & (1 << (7 - (x & 0x7)))) != 0 ? (byte)0xff : 0;
+						buffer[offset] = ((maskData[maskOffset + (x >> 3)]) & (1 << (7 - (x & 0x7)))) != 0 ? cast(byte)0xff : 0;
 						offset += 4;
 					}
 					maskOffset += maskBpl;
 				}
 			} else if (source.alpha != -1) {
-				byte alpha = (byte)source.alpha;
+				byte alpha = cast(byte)source.alpha;
 				for (int i=3; i<buffer.length; i+=4) {
 					buffer[i] = alpha;
 				}
@@ -350,7 +357,7 @@
 				}
 			}
 		}
-		OS.memmove(data, buffer, stride * height);
+		memmove(data, buffer.ptr, stride * height);
 		handle = OS.gdk_cursor_new_from_pixbuf(display, pixbuf, hotspotX, hotspotY);
 		OS.g_object_unref(pixbuf);
 	} else {
@@ -364,7 +371,7 @@
 				source.width, source.height, 1, ImageData.bwPalette(),
 				1, null, 0, null, null, -1, -1, 0, 0, 0, 0, 0);
 
-			byte[] newReds = new byte[]{0, (byte)255}, newGreens = newReds, newBlues = newReds;
+			byte[] newReds = [ cast(byte)0, cast(byte)255 ], newGreens = newReds, newBlues = newReds;
 
 			/* Convert the source to a black and white image of depth 1 */
 			PaletteData palette = source.palette;
@@ -383,9 +390,9 @@
 				for (int i = 0; i < rgbs.length; i++) {
 					RGB rgb = rgbs[i];
 					if (rgb == null) continue;
-					srcReds[i] = (byte)rgb.red;
-					srcGreens[i] = (byte)rgb.green;
-					srcBlues[i] = (byte)rgb.blue;
+					srcReds[i] = cast(byte)rgb.red;
+					srcGreens[i] = cast(byte)rgb.green;
+					srcBlues[i] = cast(byte)rgb.blue;
 				}
 				ImageData.blit(ImageData.BLIT_SRC,
 						source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, srcReds, srcGreens, srcBlues,
@@ -402,7 +409,7 @@
 		byte[] data = source.data;
 		for (int i = 0; i < data.length; i++) {
 			byte s = data[i];
-			sourceData[i] = (byte)(((s & 0x80) >> 7) |
+			sourceData[i] = cast(byte)(((s & 0x80) >> 7) |
 				((s & 0x40) >> 5) |
 				((s & 0x20) >> 3) |
 				((s & 0x10) >> 1) |
@@ -415,7 +422,7 @@
 		data = mask.data;
 		for (int i = 0; i < data.length; i++) {
 			byte s = data[i];
-			maskData[i] = (byte)(((s & 0x80) >> 7) |
+			maskData[i] = cast(byte)(((s & 0x80) >> 7) |
 				((s & 0x40) >> 5) |
 				((s & 0x20) >> 3) |
 				((s & 0x10) >> 1) |
@@ -427,23 +434,23 @@
 		maskData = ImageData.convertPad(maskData, mask.width, mask.height, mask.depth, mask.scanlinePad, 1);
 		handle = createCursor(sourceData, maskData, source.width, source.height, hotspotX, hotspotY, false);
 	}
-	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	if (handle is null) SWT.error(SWT.ERROR_NO_HANDLES);
 	if (device.tracking) device.new_Object(this);
 }
 
-int /*long*/ createCursor(byte[] sourceData, byte[] maskData, int width, int height, int hotspotX, int hotspotY, boolean reverse) {
-	int /*long*/ sourcePixmap = OS.gdk_bitmap_create_from_data(0, sourceData, width, height);
-	int /*long*/ maskPixmap = OS.gdk_bitmap_create_from_data(0, maskData, width, height);
-	int /*long*/ cursor = 0;
-	if (sourcePixmap != 0 && maskPixmap != 0) {
-		GdkColor foreground = new GdkColor();
-		if (!reverse) foreground.red = foreground.green = foreground.blue = (short)0xFFFF;
-		GdkColor background = new GdkColor();
-		if (reverse) background.red = background.green = background.blue = (short)0xFFFF;
-		cursor = OS.gdk_cursor_new_from_pixmap (sourcePixmap, maskPixmap, foreground, background, hotspotX, hotspotY);
+GdkCursor* createCursor(byte[] sourceData, byte[] maskData, int width, int height, int hotspotX, int hotspotY, bool reverse) {
+	auto sourcePixmap = OS.gdk_bitmap_create_from_data(null, cast(char*)sourceData.ptr, width, height);
+	auto maskPixmap = OS.gdk_bitmap_create_from_data(null, cast(char*)maskData.ptr, width, height);
+	GdkCursor* cursor = null;
+	if (sourcePixmap !is null && maskPixmap !is null) {
+		GdkColor* foreground = new GdkColor();
+		if (!reverse) foreground.red = foreground.green = foreground.blue = 0xFFFF;
+		GdkColor* background = new GdkColor();
+		if (reverse) background.red = background.green = background.blue = 0xFFFF;
+		cursor = OS.gdk_cursor_new_from_pixmap (cast(GdkPixmap*)sourcePixmap, cast(GdkPixmap*)maskPixmap, foreground, background, hotspotX, hotspotY);
 	}
-	if (sourcePixmap != 0) OS.g_object_unref (sourcePixmap);
-	if (maskPixmap != 0) OS.g_object_unref (maskPixmap);
+	if (sourcePixmap !is null) OS.g_object_unref (sourcePixmap);
+	if (maskPixmap !is null) OS.g_object_unref (maskPixmap);
 	return cursor;
 }
 
@@ -453,10 +460,10 @@
  * they allocate.
  */
 public void dispose() {
-	if (handle == 0) return;
+	if (handle is null) return;
 	if (device.isDisposed()) return;
 	OS.gdk_cursor_destroy(handle);
-	handle = 0;
+	handle = null;
 	if (device.tracking) device.dispose_Object(this);
 	device = null;
 }
@@ -471,11 +478,12 @@
  *
  * @see #hashCode
  */
-public boolean equals(Object object) {
-	if (object == this) return true;
-	if (!(object instanceof Cursor)) return false;
-	Cursor cursor = (Cursor) object;
-	return device == cursor.device && handle == cursor.handle;
+public override int opEquals(Object object) {
+	if (object is this) return true;
+	if ( auto cursor = cast(Cursor)object ){
+        return device is cursor.device && handle is cursor.handle;
+    }
+    return false;
 }
 
 /**
@@ -493,7 +501,7 @@
  *
  * @private
  */
-public static Cursor gtk_new(Device device, int /*long*/ handle) {
+public static Cursor gtk_new(Device device, GdkCursor* handle) {
 	if (device == null) device = Device.getDevice();
 	Cursor cursor = new Cursor();
 	cursor.handle = handle;
@@ -511,8 +519,8 @@
  *
  * @see #equals
  */
-public int hashCode() {
-	return (int)/*64*/handle;
+public override hash_t toHash() {
+	return cast(hash_t)handle;
 }
 
 /**
@@ -525,8 +533,8 @@
  *
  * @return <code>true</code> when the cursor is disposed and <code>false</code> otherwise
  */
-public boolean isDisposed() {
-	return handle == 0;
+public bool isDisposed() {
+	return handle is null;
 }
 
 /**
@@ -535,10 +543,9 @@
  *
  * @return a string representation of the receiver
  */
-public String toString () {
+public override char[] toString () {
 	if (isDisposed()) return "Cursor {*DISPOSED*}";
-	return "Cursor {" + handle + "}";
+	return Format( "Cursor {{{}}", handle );
 }
 
 }
-++++/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cairo/Cairo.d	Mon Jan 07 08:07:46 2008 +0100
@@ -0,0 +1,274 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+module dwt.internal.cairo.Cairo;
+
+import  dwt.internal.gtk.c.cairo;
+import  dwt.internal.gtk.c.cairotypes;
+import  dwt.internal.Platform;
+
+import tango.core.Traits;
+private extern(C) {
+cairo_surface_t *
+cairo_xlib_surface_create (Display     *dpy,
+               XID/*Drawable*/ drawable,
+               Visual      *visual,
+               int      width,
+               int      height);
+}
+
+template NameOfFunc(alias f) {
+    // Note: highly dependent on the .stringof formatting
+    // the value begins with "& " which is why the first two chars are cut off
+    const char[] NameOfFunc = (&f).stringof[2 .. $];
+}
+
+template ForwardGtkCairoCFunc( alias cFunc ) {
+    alias ParameterTupleOf!(cFunc) P;
+    alias ReturnTypeOf!(cFunc) R;
+    mixin("public static R " ~ NameOfFunc!(cFunc) ~ "( P p ){
+        lock.lock();
+        scope(exit) lock.unlock();
+        return cFunc(p);
+    }");
+}
+
+public class Cairo : Platform {
+
+	/** Constants */
+	public static const int CAIRO_ANTIALIAS_DEFAULT = 0;
+	public static const int CAIRO_ANTIALIAS_NONE = 1;
+	public static const int CAIRO_ANTIALIAS_GRAY = 2;
+	public static const int CAIRO_ANTIALIAS_SUBPIXEL = 3;
+	public static const int CAIRO_FORMAT_ARGB32 = 0;
+	public static const int CAIRO_FORMAT_RGB24 = 1;
+	public static const int CAIRO_FORMAT_A8 = 2;
+	public static const int CAIRO_FORMAT_A1 = 3;
+	public static const int CAIRO_OPERATOR_CLEAR = 0;
+	public static const int CAIRO_OPERATOR_SRC = 1;
+	public static const int CAIRO_OPERATOR_DST = 2;
+	public static const int CAIRO_OPERATOR_OVER = 3;
+	public static const int CAIRO_OPERATOR_OVER_REVERSE = 4;
+	public static const int CAIRO_OPERATOR_IN = 5;
+	public static const int CAIRO_OPERATOR_IN_REVERSE = 6;
+	public static const int CAIRO_OPERATOR_OUT = 7;
+	public static const int CAIRO_OPERATOR_OUT_REVERSE = 8;
+	public static const int CAIRO_OPERATOR_ATOP = 9;
+	public static const int CAIRO_OPERATOR_ATOP_REVERSE = 10;
+	public static const int CAIRO_OPERATOR_XOR = 11;
+	public static const int CAIRO_OPERATOR_ADD = 12;
+	public static const int CAIRO_OPERATOR_SATURATE = 13;
+	public static const int CAIRO_FILL_RULE_WINDING = 0;
+	public static const int CAIRO_FILL_RULE_EVEN_ODD = 1;
+	public static const int CAIRO_LINE_CAP_BUTT = 0;
+	public static const int CAIRO_LINE_CAP_ROUND = 1;
+	public static const int CAIRO_LINE_CAP_SQUARE = 2;
+	public static const int CAIRO_LINE_JOIN_MITER = 0;
+	public static const int CAIRO_LINE_JOIN_ROUND = 1;
+	public static const int CAIRO_LINE_JOIN_BEVEL = 2;
+	public static const int CAIRO_FONT_SLANT_NORMAL = 0;
+	public static const int CAIRO_FONT_SLANT_ITALIC = 1;
+	public static const int CAIRO_FONT_SLANT_OBLIQUE = 2;
+	public static const int CAIRO_FONT_WEIGHT_NORMAL = 0;
+	public static const int CAIRO_FONT_WEIGHT_BOLD = 1;
+	public static const int CAIRO_STATUS_SUCCESS = 0;
+	public static const int CAIRO_STATUS_NO_MEMORY = 1;
+	public static const int CAIRO_STATUS_INVALID_RESTORE = 2;
+	public static const int CAIRO_STATUS_INVALID_POP_GROUP = 3;
+	public static const int CAIRO_STATUS_NO_CURRENT_POINT = 4;
+	public static const int CAIRO_STATUS_INVALID_MATRIX = 5;
+	public static const int CAIRO_STATUS_NO_TARGET_SURFACE = 6;
+	public static const int CAIRO_STATUS_NULL_POINTER =7;
+	public static const int CAIRO_SURFACE_TYPE_IMAGE = 0;
+	public static const int CAIRO_SURFACE_TYPE_PDF = 1;
+    public static const int CAIRO_SURFACE_TYPE_PS = 2;
+    public static const int CAIRO_SURFACE_TYPE_XLIB = 3;
+    public static const int CAIRO_SURFACE_TYPE_XCB = 4;
+    public static const int CAIRO_SURFACE_TYPE_GLITZ = 5;
+    public static const int CAIRO_SURFACE_TYPE_QUARTZ = 6;
+    public static const int CAIRO_SURFACE_TYPE_WIN32 = 7;
+    public static const int CAIRO_SURFACE_TYPE_BEOS = 8;
+    public static const int CAIRO_SURFACE_TYPE_DIRECTFB = 9;
+    public static const int CAIRO_SURFACE_TYPE_SVG = 10;
+	public static const int CAIRO_FILTER_FAST = 0;
+	public static const int CAIRO_FILTER_GOOD = 1;
+	public static const int CAIRO_FILTER_BEST = 2;
+	public static const int CAIRO_FILTER_NEAREST = 3;
+	public static const int CAIRO_FILTER_BILINEAR = 4;
+	public static const int CAIRO_FILTER_GAUSSIAN = 5;
+	public static const int CAIRO_EXTEND_NONE = 0;
+	public static const int CAIRO_EXTEND_REPEAT = 1;
+	public static const int CAIRO_EXTEND_REFLECT = 2;
+	public static const int CAIRO_EXTEND_PAD = 3;
+	public static const int CAIRO_PATH_MOVE_TO = 0;
+	public static const int CAIRO_PATH_LINE_TO = 1;
+	public static const int CAIRO_PATH_CURVE_TO = 2;
+	public static const int CAIRO_PATH_CLOSE_PATH = 3;
+/+
+    mixin ForwardGtkCairoCFunc!(.cairo_font_extents_t_sizeof );
+    mixin ForwardGtkCairoCFunc!(.cairo_path_data_t_sizeof );
+    mixin ForwardGtkCairoCFunc!(.cairo_path_t_sizeof );
+    mixin ForwardGtkCairoCFunc!(.cairo_text_extents_t_sizeof );
+    mixin ForwardGtkCairoCFunc!(.CAIRO_VERSION_ENCODE);
+    mixin ForwardGtkCairoCFunc!(._cairo_append_path);
+    mixin ForwardGtkCairoCFunc!(._cairo_arc);
+    mixin ForwardGtkCairoCFunc!(._cairo_arc_negative);
+    mixin ForwardGtkCairoCFunc!(._cairo_clip);
+    mixin ForwardGtkCairoCFunc!(._cairo_clip_preserve);
+    mixin ForwardGtkCairoCFunc!(._cairo_close_path);
+    mixin ForwardGtkCairoCFunc!(._cairo_copy_page);
+    mixin ForwardGtkCairoCFunc!(._cairo_copy_path);
+    mixin ForwardGtkCairoCFunc!(._cairo_copy_path_flat);
+    mixin ForwardGtkCairoCFunc!(._cairo_create);
+    mixin ForwardGtkCairoCFunc!(._cairo_curve_to);
+    mixin ForwardGtkCairoCFunc!(._cairo_destroy);
+    mixin ForwardGtkCairoCFunc!(._cairo_device_to_user);
+    mixin ForwardGtkCairoCFunc!(._cairo_device_to_user_distance);
+    mixin ForwardGtkCairoCFunc!(._cairo_fill);
+    mixin ForwardGtkCairoCFunc!(._cairo_fill_extents);
+    mixin ForwardGtkCairoCFunc!(._cairo_fill_preserve);
+    mixin ForwardGtkCairoCFunc!(._cairo_font_extents);
+    mixin ForwardGtkCairoCFunc!(._cairo_font_options_create);
+    mixin ForwardGtkCairoCFunc!(._cairo_font_options_destroy);
+    mixin ForwardGtkCairoCFunc!(._cairo_font_options_get_antialias);
+    mixin ForwardGtkCairoCFunc!(._cairo_font_options_set_antialias);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_antialias);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_current_point);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_fill_rule);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_font_face);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_font_matrix);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_font_options);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_line_cap);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_line_join);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_line_width);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_matrix);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_miter_limit);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_operator);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_source);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_target);
+    mixin ForwardGtkCairoCFunc!(._cairo_get_tolerance);
+    mixin ForwardGtkCairoCFunc!(._cairo_glyph_extents);
+    mixin ForwardGtkCairoCFunc!(._cairo_glyph_path);
+    mixin ForwardGtkCairoCFunc!(._cairo_identity_matrix);
+    mixin ForwardGtkCairoCFunc!(._cairo_image_surface_create);
+    +/
+    mixin ForwardGtkCairoCFunc!(.cairo_image_surface_create_for_data);
+    /+
+    mixin ForwardGtkCairoCFunc!(._cairo_image_surface_get_height);
+    mixin ForwardGtkCairoCFunc!(._cairo_image_surface_get_width);
+    mixin ForwardGtkCairoCFunc!(._cairo_in_fill);
+    mixin ForwardGtkCairoCFunc!(._cairo_in_stroke);
+    mixin ForwardGtkCairoCFunc!(._cairo_line_to);
+    mixin ForwardGtkCairoCFunc!(._cairo_mask);
+    mixin ForwardGtkCairoCFunc!(._cairo_mask_surface);
+    mixin ForwardGtkCairoCFunc!(._cairo_matrix_init);
+    mixin ForwardGtkCairoCFunc!(._cairo_matrix_init_identity);
+    mixin ForwardGtkCairoCFunc!(._cairo_matrix_init_rotate);
+    mixin ForwardGtkCairoCFunc!(._cairo_matrix_init_scale);
+    mixin ForwardGtkCairoCFunc!(._cairo_matrix_init_translate);
+    mixin ForwardGtkCairoCFunc!(._cairo_matrix_invert);
+    mixin ForwardGtkCairoCFunc!(._cairo_matrix_multiply);
+    mixin ForwardGtkCairoCFunc!(._cairo_matrix_rotate);
+    mixin ForwardGtkCairoCFunc!(._cairo_matrix_scale);
+    mixin ForwardGtkCairoCFunc!(._cairo_matrix_transform_distance);
+    mixin ForwardGtkCairoCFunc!(._cairo_matrix_transform_point);
+    mixin ForwardGtkCairoCFunc!(._cairo_matrix_translate);
+    mixin ForwardGtkCairoCFunc!(._cairo_move_to);
+    mixin ForwardGtkCairoCFunc!(._cairo_new_path);
+    mixin ForwardGtkCairoCFunc!(._cairo_paint);
+    mixin ForwardGtkCairoCFunc!(._cairo_paint_with_alpha);
+    mixin ForwardGtkCairoCFunc!(._cairo_path_destroy);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_add_color_stop_rgb);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_add_color_stop_rgba);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_create_for_surface);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_create_linear);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_create_radial);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_destroy);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_get_extend);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_get_filter);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_get_matrix);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_reference);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_set_extend);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_set_filter);
+    mixin ForwardGtkCairoCFunc!(._cairo_pattern_set_matrix);
+    mixin ForwardGtkCairoCFunc!(._cairo_pdf_surface_set_size);
+    mixin ForwardGtkCairoCFunc!(._cairo_ps_surface_set_size);
+    mixin ForwardGtkCairoCFunc!(._cairo_rectangle);
+    mixin ForwardGtkCairoCFunc!(._cairo_reference);
+    mixin ForwardGtkCairoCFunc!(._cairo_rel_curve_to);
+    mixin ForwardGtkCairoCFunc!(._cairo_rel_line_to);
+    mixin ForwardGtkCairoCFunc!(._cairo_rel_move_to);
+    mixin ForwardGtkCairoCFunc!(._cairo_reset_clip);
+    mixin ForwardGtkCairoCFunc!(._cairo_restore);
+    mixin ForwardGtkCairoCFunc!(._cairo_rotate);
+    mixin ForwardGtkCairoCFunc!(._cairo_save);
+    mixin ForwardGtkCairoCFunc!(._cairo_scale);
+    mixin ForwardGtkCairoCFunc!(._cairo_select_font_face);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_antialias);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_dash);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_fill_rule);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_font_face);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_font_matrix);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_font_options);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_font_size);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_line_cap);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_line_join);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_line_width);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_matrix);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_miter_limit);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_operator);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_source);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_source_rgb);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_source_rgba);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_source_surface);
+    mixin ForwardGtkCairoCFunc!(._cairo_set_tolerance);
+    mixin ForwardGtkCairoCFunc!(._cairo_show_glyphs);
+    mixin ForwardGtkCairoCFunc!(._cairo_show_page);
+    mixin ForwardGtkCairoCFunc!(._cairo_show_text);
+    mixin ForwardGtkCairoCFunc!(._cairo_status);
+    mixin ForwardGtkCairoCFunc!(._cairo_status_to_string);
+    mixin ForwardGtkCairoCFunc!(._cairo_stroke);
+    mixin ForwardGtkCairoCFunc!(._cairo_stroke_extents);
+    mixin ForwardGtkCairoCFunc!(._cairo_stroke_preserve);
+    mixin ForwardGtkCairoCFunc!(._cairo_surface_create_similar);
+    +/
+    mixin ForwardGtkCairoCFunc!(.cairo_surface_destroy);
+    /+
+    mixin ForwardGtkCairoCFunc!(._cairo_surface_finish);
+    mixin ForwardGtkCairoCFunc!(._cairo_surface_get_type);
+    mixin ForwardGtkCairoCFunc!(._cairo_surface_get_user_data);
+    mixin ForwardGtkCairoCFunc!(._cairo_surface_reference);
+    mixin ForwardGtkCairoCFunc!(._cairo_surface_set_device_offset);
+    mixin ForwardGtkCairoCFunc!(._cairo_surface_set_fallback_resolution);
+    mixin ForwardGtkCairoCFunc!(._cairo_surface_set_user_data);
+    mixin ForwardGtkCairoCFunc!(._cairo_text_extents);
+    mixin ForwardGtkCairoCFunc!(._cairo_text_path);
+    mixin ForwardGtkCairoCFunc!(._cairo_transform);
+    mixin ForwardGtkCairoCFunc!(._cairo_translate);
+    mixin ForwardGtkCairoCFunc!(._cairo_user_to_device);
+    mixin ForwardGtkCairoCFunc!(._cairo_user_to_device_distance);
+    mixin ForwardGtkCairoCFunc!(.cairo_version);
+    +/
+    mixin ForwardGtkCairoCFunc!(.cairo_xlib_surface_create);
+    /+
+    mixin ForwardGtkCairoCFunc!(._cairo_xlib_surface_create_for_bitmap);
+    mixin ForwardGtkCairoCFunc!(._cairo_xlib_surface_set_size);
++/
+}
--- a/dwt/internal/gtk/OS.d	Mon Jan 07 07:47:32 2008 +0100
+++ b/dwt/internal/gtk/OS.d	Mon Jan 07 08:07:46 2008 +0100
@@ -904,7 +904,7 @@
     mixin ForwardGtkOsCFunc!(.gdk_colormap_free_colors);
     mixin ForwardGtkOsCFunc!(.gdk_colormap_get_system);
     mixin ForwardGtkOsCFunc!(.gdk_colormap_query_color);
-//    mixin ForwardGtkOsCFunc!(.gdk_cursor_destroy);
+    mixin ForwardGtkOsCFunc!(.gdk_cursor_destroy); // is alias for gdk_cursor_unref
     mixin ForwardGtkOsCFunc!(.gdk_cursor_new);
     mixin ForwardGtkOsCFunc!(.gdk_cursor_new_from_pixmap);
     mixin ForwardGtkOsCFunc!(.gdk_cursor_new_from_pixbuf);
--- a/dwt/internal/gtk/c/gdk.d	Mon Jan 07 07:47:32 2008 +0100
+++ b/dwt/internal/gtk/c/gdk.d	Mon Jan 07 08:07:46 2008 +0100
@@ -450,6 +450,10 @@
 	GdkPixbuf* function(GdkCursor* cursor)gdk_cursor_get_image;
 	GdkCursor* function(GdkCursor* cursor)gdk_cursor_ref;
 	void function(GdkCursor* cursor)gdk_cursor_unref;
+    void gdk_cursor_destroy( GdkCursor* cursor ){
+        gdk_cursor_unref(cursor);
+    }
+
 
 	// gdk.Window