# HG changeset patch
# User Jacob Carlborg
# Date 1223634588 -7200
# Node ID 642f460a0908aa2db575d184d2cc0c1a8d0a05a7
# Parent db5a898b2119d9e6e60650d573e5a42057213aa7
Fixed a lot of compile errors, a "hello world" app compiles now
diff -r db5a898b2119 -r 642f460a0908 dwt/DWT.d
--- a/dwt/DWT.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/DWT.d Fri Oct 10 12:29:48 2008 +0200
@@ -1847,31 +1847,31 @@
* ASCII character convenience constant for the backspace character
* (value is the char
'\b').
*/
- public static final char BS = '\b';
+ public static const char BS = '\b';
/**
* ASCII character convenience constant for the carriage return character
* (value is the char
'\r').
*/
- public static final char CR = '\r';
+ public static const char CR = '\r';
/**
* ASCII character convenience constant for the delete character
* (value is the char
with value 127).
*/
- public static final char DEL = 0x7F;
+ public static const char DEL = 0x7F;
/**
* ASCII character convenience constant for the escape character
* (value is the char
with value 27).
*/
- public static final char ESC = 0x1B;
+ public static const char ESC = 0x1B;
/**
* ASCII character convenience constant for the line feed character
* (value is the char
'\n').
*/
- public static final char LF = '\n';
+ public static const char LF = '\n';
/**
* ASCII character convenience constant for the tab character
@@ -1879,7 +1879,7 @@
*
* @since 2.1
*/
- public static final char TAB = '\t';
+ public static const char TAB = '\t';
/**
* keyboard and/or mouse event mask indicating that the ALT key
diff -r db5a898b2119 -r 642f460a0908 dwt/accessibility/Accessible.d
--- a/dwt/accessibility/Accessible.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/accessibility/Accessible.d Fri Oct 10 12:29:48 2008 +0200
@@ -48,6 +48,23 @@
this (Control control) {
this.control = control;
}
+
+ /**
+ * Invokes platform specific functionality to allocate a new 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 SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ *
+ *
+ * @param control the control to get the accessible object for
+ * @return the platform specific accessible object
+ */
+ public static Accessible internal_new_Accessible(Control control) {
+ return new Accessible(control);
+ }
/**
* Adds the listener to the collection of listeners who will
diff -r db5a898b2119 -r 642f460a0908 dwt/accessibility/AccessibleControlEvent.d
--- a/dwt/accessibility/AccessibleControlEvent.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/accessibility/AccessibleControlEvent.d Fri Oct 10 12:29:48 2008 +0200
@@ -13,9 +13,12 @@
*******************************************************************************/
module dwt.accessibility.AccessibleControlEvent;
+import dwt.internal.DWTEventObject;
+
+import tango.text.convert.Format;
+
import dwt.accessibility.Accessible;
import dwt.dwthelper.utils;
-import dwt.internal.DWTEventObject;
/**
* Instances of this class are sent as a result of
@@ -60,14 +63,14 @@
* @return a String representation of the event
*/
public String toString () {
- return "AccessibleControlEvent {childID=" + childID + //$NON-NLS-1$
- " accessible=" + accessible + //$NON-NLS-1$
- " x=" + x + //$NON-NLS-1$
- " y=" + y + //$NON-NLS-1$
- " width=" + width + //$NON-NLS-1$
- " height=" + height + //$NON-NLS-1$
- " detail=" + detail + //$NON-NLS-1$
- " result=" + result + //$NON-NLS-1$
- "}"; //$NON-NLS-1$
+ return Format("AccessibleControlEvent {childID={}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}" , childID , //$NON-NLS-1$
+ " accessible=" , accessible , //$NON-NLS-1$
+ " x=" , x , //$NON-NLS-1$
+ " y=" , y , //$NON-NLS-1$
+ " width=" , width , //$NON-NLS-1$
+ " height=" , height , //$NON-NLS-1$
+ " detail=" , detail , //$NON-NLS-1$
+ " result=" , result , //$NON-NLS-1$
+ "}"); //$NON-NLS-1$
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/dwthelper/utils.d
--- a/dwt/dwthelper/utils.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/dwthelper/utils.d Fri Oct 10 12:29:48 2008 +0200
@@ -155,15 +155,15 @@
}
public static String toHexString( int i ){
- return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Hex );
+ return tango.text.convert.Integer.toString(i, "x" );
}
public static String toOctalString( int i ){
- return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Octal );
+ return tango.text.convert.Integer.toString(i, "o" );
}
public static String toBinaryString( int i ){
- return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Binary );
+ return tango.text.convert.Integer.toString(i, "b" );
}
public static String toString( int i ){
@@ -664,15 +664,18 @@
}
}
+public String fromStringz (char* str)
+{
+ return tango.stdc.stringz.fromStringz(str);
+}
+
static String toHex(uint value, bool prefix = true, int radix = 8){
return tango.text.convert.Integer.toString(
- value,
- radix is 10 ? tango.text.convert.Integer.Style.Signed :
- radix is 8 ? tango.text.convert.Integer.Style.Octal :
- radix is 16 ? tango.text.convert.Integer.Style.Hex :
- tango.text.convert.Integer.Style.Signed,
- prefix ? tango.text.convert.Integer.Flags.Prefix : tango.text.convert.Integer.Flags.None
- );
+ value,
+ radix is 10 ? "d" :
+ radix is 8 ? "o" :
+ radix is 16 ? "x" :
+ "d" );
}
class RuntimeException : Exception {
diff -r db5a898b2119 -r 642f460a0908 dwt/graphics/Device.d
--- a/dwt/graphics/Device.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/graphics/Device.d Fri Oct 10 12:29:48 2008 +0200
@@ -346,7 +346,7 @@
public Point getDPI () {
checkDevice ();
NSDictionary dictionary = NSScreen.mainScreen().deviceDescription();
- NSValue value = new NSValue(dictionary.objectForKey(new id(OS.NSDeviceResolution().id_)).id_);
+ 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);
}
@@ -539,7 +539,7 @@
* @param hDC the platform specific GC handle
* @param data the platform specific GC data
*/
-public abstract void internal_dispose_GC (int handle, GCData data);
+public abstract void internal_dispose_GC (objc.id handle, GCData data);
/**
* Returns true
if the device has been disposed,
diff -r db5a898b2119 -r 642f460a0908 dwt/graphics/Font.d
--- a/dwt/graphics/Font.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/graphics/Font.d Fri Oct 10 12:29:48 2008 +0200
@@ -151,11 +151,11 @@
init_();
}
-/*public*/ this(Device device, String name, float height, int style) {
+/+/*public*/ this(Device device, String name, float height, int style) {
super(device);
init_(name, height, style, null);
init_();
-}
+}+/
void destroy() {
handle.release();
diff -r db5a898b2119 -r 642f460a0908 dwt/graphics/GC.d
--- a/dwt/graphics/GC.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/graphics/GC.d Fri Oct 10 12:29:48 2008 +0200
@@ -651,7 +651,7 @@
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.NSBackgroundColorAttributeName());
+ dict.setObject(color, OS.FuncNSBackgroundColorAttributeName());
}
size_t length = string.length();
char[] chars = new char[length];
@@ -2051,8 +2051,8 @@
}
}
region.add(cast(int)rect.x, cast(int)rect.y, cast(int)rect.width, cast(int)rect.height);
- NSRect paintRect = *data.paintRect;
- if (paintRect !is NSRect.init) {
+ NSRect* paintRect = data.paintRect;
+ if (paintRect !is null) {
region.intersect(cast(int)paintRect.x, cast(int)paintRect.y, cast(int)paintRect.width, cast(int)paintRect.height);
}
if (data.clipPath !is null) {
diff -r db5a898b2119 -r 642f460a0908 dwt/graphics/GCData.d
--- a/dwt/graphics/GCData.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/graphics/GCData.d Fri Oct 10 12:29:48 2008 +0200
@@ -67,6 +67,9 @@
public NSBezierPath path;
public NSAffineTransform transform, inverseTransform;
public NSBezierPath clipPath;
- public NSView* view;
+ public NSView view;
public NSSize* size;
+
+ public NSRect paintRectStruct;
+ public NSSize sizeStruct;
}
diff -r db5a898b2119 -r 642f460a0908 dwt/graphics/RGB.d
--- a/dwt/graphics/RGB.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/graphics/RGB.d Fri Oct 10 12:29:48 2008 +0200
@@ -184,7 +184,7 @@
hue *= 60;
if (hue < 0) hue += 360;
}
- return new float[] [hue, saturation, brightness];
+ return [hue, saturation, brightness];
}
/**
diff -r db5a898b2119 -r 642f460a0908 dwt/graphics/Region.d
--- a/dwt/graphics/Region.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/graphics/Region.d Fri Oct 10 12:29:48 2008 +0200
@@ -249,7 +249,7 @@
return contains(pt.x, pt.y);
}
-NSAffineTransform transform;
+static NSAffineTransform transform;
void convertRgn(NSAffineTransform transform) {
QuickdrawTypes.RgnHandle newRgn = OS.NewRgn();
RegionToRectsUPP proc = &Region.convertRgn_;
diff -r db5a898b2119 -r 642f460a0908 dwt/graphics/TextLayout.d
--- a/dwt/graphics/TextLayout.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/graphics/TextLayout.d Fri Oct 10 12:29:48 2008 +0200
@@ -29,6 +29,8 @@
import dwt.internal.cocoa.NSTextStorage;
import dwt.internal.cocoa.OS;
+import tango.text.convert.Format;
+
import dwt.dwthelper.utils;
import dwt.graphics.Color;
import dwt.graphics.Device;
@@ -42,6 +44,9 @@
import dwt.graphics.Region;
import dwt.graphics.Resource;
import dwt.graphics.TextStyle;
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSText;
/**
* TextLayout
is a graphic object that represents
@@ -84,7 +89,7 @@
int start;
public String toString () {
- return "StyleItem {" + start + ", " + style + "}";
+ return Format("StyleItem {{}{}{}{}" , start , ", " , style , "}");
}
}
@@ -132,7 +137,7 @@
textStorage.initWithString_(str);
layoutManager = cast(NSLayoutManager)(new NSLayoutManager()).alloc().init();
textContainer = cast(NSTextContainer)(new NSTextContainer()).alloc();
- NSSize size = new NSSize();
+ NSSize size = NSSize();
size.width = wrapWidth !is -1 ? wrapWidth : Float.MAX_VALUE;
size.height = Float.MAX_VALUE;
textContainer.initWithContainerSize(size);
@@ -141,21 +146,21 @@
textStorage.beginEditing();
Font defaultFont = font !is null ? font : device.systemFont;
- NSRange range = new NSRange();
+ NSRange range = NSRange();
range.length = str.length();
textStorage.addAttribute(OS.NSFontAttributeName(), defaultFont.handle, range);
NSMutableParagraphStyle paragraph = cast(NSMutableParagraphStyle)(new NSMutableParagraphStyle()).alloc().init();
- int align_ = OS.NSLeftTextAlignment;
+ NSTextAlignment align_ = NSLeftTextAlignment;
if (justify) {
- align_ = OS.NSJustifiedTextAlignment;
+ align_ = NSJustifiedTextAlignment;
} else {
switch (alignment) {
case DWT.CENTER:
- align_ = OS.NSCenterTextAlignment;
+ align_ = NSCenterTextAlignment;
break;
case DWT.RIGHT:
- align_ = OS.NSRightTextAlignment;
+ align_ = NSRightTextAlignment;
}
}
paragraph.setAlignment(align_);
@@ -186,7 +191,7 @@
Color background = style.background;
if (background !is null) {
NSColor color = NSColor.colorWithDeviceRed(background.handle[0], background.handle[1], background.handle[2], 1);
- textStorage.addAttribute(OS.NSBackgroundColorAttributeName(), color, range);
+ textStorage.addAttribute(OS.NSBackgroundColorAttributeName, color, range);
}
if (style.strikeout) {
textStorage.addAttribute(OS.NSStrikethroughStyleAttributeName(), NSNumber.numberWithInt(OS.NSUnderlineStyleSingle), range);
@@ -229,11 +234,11 @@
layoutManager.glyphRangeForTextContainer(textContainer);
int numberOfLines, index, numberOfGlyphs = layoutManager.numberOfGlyphs();
- int rangePtr = OS.malloc(NSRange.sizeof);
- NSRange lineRange = new NSRange();
+ 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);
- OS.memmove(lineRange, rangePtr, NSRange.sizeof);
+ OS.memmove(&lineRange, rangePtr, NSRange.sizeof);
index = lineRange.location + lineRange.length;
}
if (numberOfLines is 0) numberOfLines++;
@@ -241,14 +246,14 @@
NSRect[] bounds = new NSRect[numberOfLines];
for (numberOfLines = 0, index = 0; index < numberOfGlyphs; numberOfLines++){
bounds[numberOfLines] = layoutManager.lineFragmentUsedRectForGlyphAtIndex_effectiveRange_withoutAdditionalLayout_(index, rangePtr, true);
- OS.memmove(lineRange, rangePtr, NSRange.sizeof);
+ OS.memmove(&lineRange, rangePtr, NSRange.sizeof);
offsets[numberOfLines] = lineRange.location;
index = lineRange.location + lineRange.length;
}
if (numberOfLines is 0) {
Font font = this.font !is null ? this.font : device.systemFont;
NSFont nsFont = font.handle;
- bounds[0] = new NSRect();
+ bounds[0] = NSRect();
bounds[0].height = Math.max(layoutManager.defaultLineHeightForFont(nsFont), ascent + descent);
}
OS.free(rangePtr);
@@ -344,20 +349,20 @@
// float[] foreground = gc.data.foreground;
// NSColor color = NSColor.colorWithDeviceRed(foreground[0], foreground[1], foreground[2], foreground[3]);
// textStorage.setForegroundColor(color);
- NSPoint pt = new NSPoint();
+ NSPoint pt = NSPoint();
pt.x = x;
pt.y = y;
- NSRange range = new NSRange();
+ NSRange range = NSRange();
range.length = layoutManager.numberOfGlyphs();
bool hasSelection = selectionStart <= selectionEnd && selectionStart !is -1 && selectionEnd !is -1;
- NSRange selectionRange = null;
+ 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]);
- layoutManager.addTemporaryAttribute(OS.NSBackgroundColorAttributeName, selectionColor, selectionRange);
+ layoutManager.addTemporaryAttribute(OS.NSBackgroundColorAttributeName, selectionColor, *selectionRange);
}
//TODO draw selection for flags (LAST_LINE_SELECTION and FULL_SELECTION)
if (range.length > 0) {
@@ -365,7 +370,7 @@
layoutManager.drawGlyphsForGlyphRange(range, pt);
}
if (selectionRange !is null) {
- layoutManager.removeTemporaryAttribute(OS.NSBackgroundColorAttributeName, selectionRange);
+ layoutManager.removeTemporaryAttribute(OS.NSBackgroundColorAttributeName, *selectionRange);
}
}
@@ -467,7 +472,7 @@
end = Math.min(Math.max(0, end), length - 1);
start = translateOffset(start);
end = translateOffset(end);
- NSRange range = new NSRange();
+ NSRange range = NSRange();
range.location = layoutManager.glyphIndexForCharacterAtIndex(start);
range.length = layoutManager.glyphIndexForCharacterAtIndex(end + 1) - range.location;
NSRect rect = layoutManager.boundingRectForGlyphRange(range, textContainer);
@@ -707,11 +712,11 @@
if (!(0 <= offset && offset <= length)) DWT.error(DWT.ERROR_INVALID_RANGE);
if (length is 0) return new Point(0, 0);
offset = translateOffset(offset);
- int glyphIndex = layoutManager.glyphIndexForCharacterAtIndex(offset);
- NSRect rect = layoutManager.lineFragmentUsedRectForGlyphAtIndex_effectiveRange_(glyphIndex, 0);
+ NSUInteger glyphIndex = layoutManager.glyphIndexForCharacterAtIndex(offset);
+ NSRect rect = layoutManager.lineFragmentUsedRectForGlyphAtIndex_effectiveRange_(glyphIndex, null);
NSPoint point = layoutManager.locationForGlyphAtIndex(glyphIndex);
if (trailing) {
- NSRange range = new NSRange();
+ NSRange range = NSRange();
range.location = glyphIndex;
range.length = 1;
NSRect bounds = layoutManager.boundingRectForGlyphRange(range, textContainer);
@@ -836,13 +841,13 @@
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 = new NSPoint();
+ NSPoint pt = NSPoint();
pt.x = x;
pt.y = y;
- float[] partialFration = new float[1];
- int glyphIndex = layoutManager.glyphIndexForPoint_inTextContainer_fractionOfDistanceThroughGlyph_(pt, textContainer, partialFration);
+ CGFloat partialFration;
+ NSUInteger glyphIndex = layoutManager.glyphIndexForPoint_inTextContainer_fractionOfDistanceThroughGlyph_(pt, textContainer, &partialFration);
int offset = layoutManager.characterIndexForGlyphAtIndex(glyphIndex);
- if (trailing !is null) trailing[0] = Math.round(partialFration[0]);
+ if (trailing !is null) trailing[0] = cast(int) Math.round(partialFration);
return Math.min(untranslateOffset(offset), length - 1);
}
@@ -1447,7 +1452,7 @@
*/
public String toString () {
if (isDisposed()) return "TextLayout {*DISPOSED*}";
- return "TextLayout {" + text + "}";
+ return "TextLayout {" ~ text ~ "}";
}
/*
diff -r db5a898b2119 -r 642f460a0908 dwt/graphics/TextStyle.d
--- a/dwt/graphics/TextStyle.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/graphics/TextStyle.d Fri Oct 10 12:29:48 2008 +0200
@@ -309,17 +309,17 @@
if (font !is null) {
if (buffer.length() > startLength) buffer.append(", ");
buffer.append("font=");
- buffer.append(font);
+ buffer.append(font.toString);
}
if (foreground !is null) {
if (buffer.length() > startLength) buffer.append(", ");
buffer.append("foreground=");
- buffer.append(foreground);
+ buffer.append(foreground.toString);
}
if (background !is null) {
if (buffer.length() > startLength) buffer.append(", ");
buffer.append("background=");
- buffer.append(background);
+ buffer.append(background.toString);
}
if (underline) {
if (buffer.length() > startLength) buffer.append(", ");
@@ -337,7 +337,7 @@
if (metrics !is null) {
if (buffer.length() > startLength) buffer.append(", ");
buffer.append("metrics=");
- buffer.append(metrics);
+ buffer.append(metrics.toString);
}
buffer.append("}");
return buffer.toString();
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/CFNumberFormatter.d
--- a/dwt/internal/cocoa/CFNumberFormatter.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/CFNumberFormatter.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,6 +7,8 @@
*/
module dwt.internal.cocoa.CFNumberFormatter;
+extern (C):
+
enum {
kCFNumberFormatterPadBeforePrefix = 0,
kCFNumberFormatterPadAfterPrefix = 1,
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/CFPropertyList.d
--- a/dwt/internal/cocoa/CFPropertyList.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/CFPropertyList.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,6 +7,8 @@
*/
module dwt.internal.cocoa.CFPropertyList;
+extern (C):
+
enum CFPropertyListFormat {
kCFPropertyListOpenStepFormat = 1,
kCFPropertyListXMLFormat_v1_0 = 100,
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/CFRunLoopRef.d
--- a/dwt/internal/cocoa/CFRunLoopRef.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/CFRunLoopRef.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,4 +7,6 @@
*/
module dwt.internal.cocoa.CFRunLoopRef;
+extern (C):
+
alias void** CFRunLoopRef;
\ No newline at end of file
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/CGBase.d
--- a/dwt/internal/cocoa/CGBase.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/CGBase.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,6 +7,8 @@
*/
module dwt.internal.cocoa.CGBase;
+extern (C):
+
static if ((void*).sizeof > int.sizeof) // 64bit target
alias double CGFloat;
else
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/CGFloat.d
--- a/dwt/internal/cocoa/CGFloat.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/CGFloat.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,6 +7,8 @@
*/
module dwt.internal.cocoa.CGFloat;
+extern (C):
+
static if ((void*).sizeof > int.sizeof) // 64bit target
alias double CGFloat;
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/CGPoint.d
--- a/dwt/internal/cocoa/CGPoint.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/CGPoint.d Fri Oct 10 12:29:48 2008 +0200
@@ -15,6 +15,8 @@
import dwt.internal.cocoa.CGFloat;
+extern (C):
+
struct CGPoint {
CGFloat x;
CGFloat y;
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/CGRect.d
--- a/dwt/internal/cocoa/CGRect.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/CGRect.d Fri Oct 10 12:29:48 2008 +0200
@@ -16,6 +16,8 @@
import dwt.internal.cocoa.CGPoint;
import dwt.internal.cocoa.CGSize;
+extern (C):
+
struct CGRect {
CGPoint origin;
CGSize size;
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/CGSize.d
--- a/dwt/internal/cocoa/CGSize.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/CGSize.d Fri Oct 10 12:29:48 2008 +0200
@@ -15,6 +15,8 @@
import dwt.internal.cocoa.CGFloat;
+extern (C):
+
struct CGSize {
CGFloat width;
CGFloat height;
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/IconRef.d
--- a/dwt/internal/cocoa/IconRef.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/IconRef.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,5 +7,7 @@
*/
module dwt.internal.cocoa.IconRef;
+extern (C):
+
alias void* OpaqueIconRef;
alias OpaqueIconRef* IconRef;
\ No newline at end of file
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSButton.d
--- a/dwt/internal/cocoa/NSButton.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSButton.d Fri Oct 10 12:29:48 2008 +0200
@@ -14,6 +14,8 @@
module dwt.internal.cocoa.NSButton;
import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSButtonCell : NSBezelStyle, NSButtonType;
+import dwt.internal.cocoa.NSCell;
import dwt.internal.cocoa.NSControl;
import dwt.internal.cocoa.NSEvent;
import dwt.internal.cocoa.NSImage;
@@ -142,7 +144,7 @@
OS.objc_msgSend(this.id_, OS.sel_setAttributedTitle_1, aString !is null ? aString.id_ : null);
}
- public void setBezelStyle (objc.id bezelStyle)
+ public void setBezelStyle (NSBezelStyle bezelStyle)
{
OS.objc_msgSend(this.id_, OS.sel_setBezelStyle_1, bezelStyle);
}
@@ -152,7 +154,7 @@
OS.objc_msgSend(this.id_, OS.sel_setBordered_1, flag);
}
- public void setButtonType (objc.id aType)
+ public void setButtonType (NSButtonType aType)
{
OS.objc_msgSend(this.id_, OS.sel_setButtonType_1, aType);
}
@@ -162,7 +164,7 @@
OS.objc_msgSend(this.id_, OS.sel_setImage_1, image !is null ? image.id_ : null);
}
- public void setImagePosition (objc.id aPosition)
+ public void setImagePosition (NSCellImagePosition aPosition)
{
OS.objc_msgSend(this.id_, OS.sel_setImagePosition_1, aPosition);
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSButtonCell.d
--- a/dwt/internal/cocoa/NSButtonCell.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSButtonCell.d Fri Oct 10 12:29:48 2008 +0200
@@ -29,6 +29,64 @@
import dwt.internal.cocoa.OS;
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,
+ 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
+{
+ NSMomentaryLightButton = 0,
+ NSPushOnPushOffButton = 1,
+ NSToggleButton = 2,
+ NSSwitchButton = 3,
+ NSRadioButton = 4,
+ NSMomentaryChangeButton = 5,
+ NSOnOffButton = 6,
+ NSMomentaryPushInButton = 7,
+ NSMomentaryPushButton = 0,
+ 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
{
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSCell.d
--- a/dwt/internal/cocoa/NSCell.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSCell.d Fri Oct 10 12:29:48 2008 +0200
@@ -100,6 +100,25 @@
alias NSControlTint.NSGraphiteControlTint NSGraphiteControlTint;
alias NSControlTint.NSClearControlTint NSClearControlTint;
+enum NSCellImagePosition : NSUInteger
+{
+ 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
{
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSControl.d
--- a/dwt/internal/cocoa/NSControl.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSControl.d Fri Oct 10 12:29:48 2008 +0200
@@ -13,6 +13,7 @@
*******************************************************************************/
module dwt.internal.cocoa.NSControl;
+import dwt.dwthelper.utils;
import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSAttributedString;
import dwt.internal.cocoa.NSCell;
@@ -44,9 +45,9 @@
return OS.objc_msgSend(this.id_, OS.sel_abortEditing) !is null;
}
- public objc.SEL action ()
+ public String action ()
{
- return cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_action);
+ return fromStringz(cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_action));
}
public objc.id alignment ()
@@ -181,9 +182,9 @@
return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_selectedTag);
}
- public bool sendAction (objc.SEL theAction, id theTarget)
+ public bool sendAction (String theAction, id theTarget)
{
- return OS.objc_msgSend(this.id_, OS.sel_sendAction_1to_1, theAction, theTarget !is null ? theTarget.id_ : null) !is null;
+ 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)
@@ -191,9 +192,9 @@
return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_sendActionOn_1, mask);
}
- public void setAction (objc.SEL aSelector)
+ public void setAction (String aSelector)
{
- OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector);
+ OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector.ptr);
}
public void setAlignment (objc.id mode)
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSMenuItem.d
--- a/dwt/internal/cocoa/NSMenuItem.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSMenuItem.d Fri Oct 10 12:29:48 2008 +0200
@@ -13,6 +13,7 @@
*******************************************************************************/
module dwt.internal.cocoa.NSMenuItem;
+import dwt.dwthelper.utils;
import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSAttributedString;
import dwt.internal.cocoa.NSImage;
@@ -159,9 +160,9 @@
return result !is null ? new NSMenuItem(result) : null;
}
- public void setAction (objc.SEL aSelector)
+ public void setAction (String aSelector)
{
- OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector);
+ OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector.ptr);
}
public void setAlternate (bool isAlternate)
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSObject.d
--- a/dwt/internal/cocoa/NSObject.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSObject.d Fri Oct 10 12:29:48 2008 +0200
@@ -1187,9 +1187,9 @@
OS.objc_msgSend(this.id_, OS.sel_performSelectorInBackground_1withObject_1, aSelector, arg !is null ? arg.id_ : null);
}
- public void performSelectorOnMainThread_withObject_waitUntilDone_ (objc.SEL aSelector, id arg, bool wait)
+ public void performSelectorOnMainThread_withObject_waitUntilDone_ (String aSelector, id arg, bool wait)
{
- OS.objc_msgSend(this.id_, OS.sel_performSelectorOnMainThread_1withObject_1waitUntilDone_1, aSelector, arg !is null ? arg.id_ : null, wait);
+ OS.objc_msgSend(this.id_, OS.sel_performSelectorOnMainThread_1withObject_1waitUntilDone_1, aSelector.ptr, arg !is null ? arg.id_ : null, wait);
}
public void performSelectorOnMainThread_withObject_waitUntilDone_modes_ (objc.SEL aSelector, id arg, bool wait, NSArray array)
@@ -1263,9 +1263,9 @@
return OS.objc_msgSend(OS.class_NSObject, OS.sel_resolveInstanceMethod_1, sel) !is null;
}
- public bool respondsToSelector (objc.SEL aSelector)
+ public bool respondsToSelector (String aSelector)
{
- return OS.objc_msgSend(this.id_, OS.sel_respondsToSelector_1, aSelector) !is null;
+ return OS.objc_msgSend(this.id_, OS.sel_respondsToSelector_1, aSelector.ptr) !is null;
}
public id retain ()
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSPoint.d
--- a/dwt/internal/cocoa/NSPoint.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSPoint.d Fri Oct 10 12:29:48 2008 +0200
@@ -15,10 +15,12 @@
import dwt.internal.cocoa.CGFloat;
+extern (C):
+
alias NSPoint* NSPointArray;
alias NSPoint* NSPointPointer;
public struct NSPoint {
- public CGFloat x;
- public CGFloat y;
+ public CGFloat x = 0;
+ public CGFloat y = 0;
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSRange.d
--- a/dwt/internal/cocoa/NSRange.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSRange.d Fri Oct 10 12:29:48 2008 +0200
@@ -15,6 +15,8 @@
import dwt.internal.cocoa.NSInteger;
+extern (C):
+
alias NSRange* NSRangePointer;
struct NSRange {
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSRect.d
--- a/dwt/internal/cocoa/NSRect.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSRect.d Fri Oct 10 12:29:48 2008 +0200
@@ -18,6 +18,8 @@
import dwt.internal.cocoa.NSPoint;
import dwt.internal.cocoa.NSSize;
+extern (C):
+
alias NSRect* NSRectArray;
alias NSRect* NSRectPointer;
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSSize.d
--- a/dwt/internal/cocoa/NSSize.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSSize.d Fri Oct 10 12:29:48 2008 +0200
@@ -15,10 +15,12 @@
import dwt.internal.cocoa.CGFloat;
+extern (C):
+
alias NSSize* NSSizeArray;
alias NSSize* NSSizePointer;
struct NSSize {
- CGFloat width;
- CGFloat height;
+ CGFloat width = 0;
+ CGFloat height = 0;
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSString.d
--- a/dwt/internal/cocoa/NSString.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSString.d Fri Oct 10 12:29:48 2008 +0200
@@ -513,7 +513,7 @@
public NSRange lineRangeForRange (NSRange range)
{
NSRange result;
- OS.objc_msgSend_struct(&result, this.id_, OS.sel_lineRangeForRange_1, &range);
+ OS.objc_msgSend_struct(&result, this.id_, OS.sel_lineRangeForRange_1, range);
return result;
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSText.d
--- a/dwt/internal/cocoa/NSText.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSText.d Fri Oct 10 12:29:48 2008 +0200
@@ -147,7 +147,7 @@
OS.objc_msgSend(this.id_, OS.sel_cut_1, sender !is null ? sender.id_ : null);
}
- public id delegatee ()
+ public id delegate_ ()
{
objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate);
return result !is null ? new id(result) : null;
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSTimer.d
--- a/dwt/internal/cocoa/NSTimer.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSTimer.d Fri Oct 10 12:29:48 2008 +0200
@@ -20,6 +20,8 @@
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
+import dwt.dwthelper.utils;
+
public class NSTimer : NSObject
{
@@ -68,11 +70,11 @@
return result !is null ? new NSTimer(result) : null;
}
- public static NSTimer static_scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ (NSTimeInterval ti, id aTarget, objc.SEL aSelector,
+ public static NSTimer static_scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ (NSTimeInterval ti, id aTarget, String aSelector,
objc.id userInfo, bool yesOrNo)
{
objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_scheduledTimerWithTimeInterval_1target_1selector_1userInfo_1repeats_1, ti,
- aTarget !is null ? aTarget.id_ : null, aSelector, userInfo, yesOrNo);
+ aTarget !is null ? aTarget.id_ : null, aSelector.ptr, userInfo, yesOrNo);
return result !is null ? new NSTimer(result) : null;
}
@@ -93,11 +95,11 @@
return result !is null ? new NSTimer(result) : null;
}
- public static NSTimer static_timerWithTimeInterval_target_selector_userInfo_repeats_ (NSTimeInterval ti, id aTarget, objc.SEL aSelector, id userInfo,
+ public static NSTimer static_timerWithTimeInterval_target_selector_userInfo_repeats_ (NSTimeInterval ti, id aTarget, String aSelector, id userInfo,
bool yesOrNo)
{
objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_timerWithTimeInterval_1target_1selector_1userInfo_1repeats_1, ti,
- aTarget !is null ? aTarget.id_ : null, aSelector, userInfo !is null ? userInfo.id_ : null, yesOrNo);
+ aTarget !is null ? aTarget.id_ : null, aSelector.ptr, userInfo !is null ? userInfo.id_ : null, yesOrNo);
return result !is null ? new NSTimer(result) : null;
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/NSWindow.d
--- a/dwt/internal/cocoa/NSWindow.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/NSWindow.d Fri Oct 10 12:29:48 2008 +0200
@@ -45,100 +45,104 @@
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
-alias int NSWindowDepth;
+extern (C)
+{
+ alias int NSWindowDepth;
-enum NSWindowOrderingMode : NSInteger
-{
+ enum NSWindowOrderingMode : NSInteger
+ {
NSWindowAbove = 1,
NSWindowBelow = -1,
NSWindowOut = 0
-}
+ }
-alias NSWindowOrderingMode.NSWindowAbove NSWindowAbove;
-alias NSWindowOrderingMode.NSWindowBelow NSWindowBelow;
-alias NSWindowOrderingMode.NSWindowOut NSWindowOut;
+ alias NSWindowOrderingMode.NSWindowAbove NSWindowAbove;
+ alias NSWindowOrderingMode.NSWindowBelow NSWindowBelow;
+ alias NSWindowOrderingMode.NSWindowOut NSWindowOut;
-enum NSWindowBackingLocation : NSUInteger
-{
+ enum NSWindowBackingLocation : NSUInteger
+ {
NSWindowBackingLocationDefault = 0,
NSWindowBackingLocationVideoMemory = 1,
NSWindowBackingLocationMainMemory = 2
-}
+ }
-alias NSWindowBackingLocation.NSWindowBackingLocationDefault NSWindowBackingLocationDefault;
-alias NSWindowBackingLocation.NSWindowBackingLocationVideoMemory NSWindowBackingLocationVideoMemory;
-alias NSWindowBackingLocation.NSWindowBackingLocationMainMemory NSWindowBackingLocationMainMemory;
+ alias NSWindowBackingLocation.NSWindowBackingLocationDefault NSWindowBackingLocationDefault;
+ alias NSWindowBackingLocation.NSWindowBackingLocationVideoMemory NSWindowBackingLocationVideoMemory;
+ alias NSWindowBackingLocation.NSWindowBackingLocationMainMemory NSWindowBackingLocationMainMemory;
-enum NSBackingStoreType
-{
+ enum NSBackingStoreType
+ {
NSBackingStoreRetained = 0,
NSBackingStoreNonretained = 1,
NSBackingStoreBuffered = 2
-}
+ }
-alias NSBackingStoreType.NSBackingStoreRetained NSBackingStoreRetained;
-alias NSBackingStoreType.NSBackingStoreNonretained NSBackingStoreNonretained;
-alias NSBackingStoreType.NSBackingStoreBuffered NSBackingStoreBuffered;
+ alias NSBackingStoreType.NSBackingStoreRetained NSBackingStoreRetained;
+ alias NSBackingStoreType.NSBackingStoreNonretained NSBackingStoreNonretained;
+ alias NSBackingStoreType.NSBackingStoreBuffered NSBackingStoreBuffered;
-enum NSWindowCollectionBehavior : NSUInteger
-{
+ enum NSWindowCollectionBehavior : NSUInteger
+ {
NSWindowCollectionBehaviorDefault = 0,
NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0,
NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1
-}
+ }
-alias NSWindowCollectionBehavior.NSWindowCollectionBehaviorDefault NSWindowCollectionBehaviorDefault;
-alias NSWindowCollectionBehavior.NSWindowCollectionBehaviorCanJoinAllSpaces NSWindowCollectionBehaviorCanJoinAllSpaces;
-alias NSWindowCollectionBehavior.NSWindowCollectionBehaviorMoveToActiveSpace NSWindowCollectionBehaviorMoveToActiveSpace;
+ alias NSWindowCollectionBehavior.NSWindowCollectionBehaviorDefault NSWindowCollectionBehaviorDefault;
+ alias NSWindowCollectionBehavior.NSWindowCollectionBehaviorCanJoinAllSpaces NSWindowCollectionBehaviorCanJoinAllSpaces;
+ alias NSWindowCollectionBehavior.NSWindowCollectionBehaviorMoveToActiveSpace NSWindowCollectionBehaviorMoveToActiveSpace;
-enum NSSelectionDirection
-{
+ enum NSSelectionDirection
+ {
NSDirectSelection = 0,
NSSelectingNext,
NSSelectingPrevious
-}
+ }
-alias NSSelectionDirection.NSDirectSelection NSDirectSelection;
-alias NSSelectionDirection.NSSelectingNext NSSelectingNext;
-alias NSSelectionDirection.NSSelectingPrevious NSSelectingPrevious;
+ alias NSSelectionDirection.NSDirectSelection NSDirectSelection;
+ alias NSSelectionDirection.NSSelectingNext NSSelectingNext;
+ alias NSSelectionDirection.NSSelectingPrevious NSSelectingPrevious;
-enum NSWindowSharingType : NSUInteger
-{
+ enum NSWindowSharingType : NSUInteger
+ {
NSWindowSharingNone = 0,
NSWindowSharingReadOnly = 1,
NSWindowSharingReadWrite = 2
-}
+ }
-alias NSWindowSharingType.NSWindowSharingNone NSWindowSharingNone;
-alias NSWindowSharingType.NSWindowSharingReadOnly NSWindowSharingReadOnly;
-alias NSWindowSharingType.NSWindowSharingReadWrite NSWindowSharingReadWrite;
+ alias NSWindowSharingType.NSWindowSharingNone NSWindowSharingNone;
+ alias NSWindowSharingType.NSWindowSharingReadOnly NSWindowSharingReadOnly;
+ alias NSWindowSharingType.NSWindowSharingReadWrite NSWindowSharingReadWrite;
-enum NSWindowButton
-{
+ enum NSWindowButton
+ {
NSWindowCloseButton,
NSWindowMiniaturizeButton,
NSWindowZoomButton,
NSWindowToolbarButton,
NSWindowDocumentIconButton
-}
+ }
-alias NSWindowButton.NSWindowCloseButton NSWindowCloseButton;
-alias NSWindowButton.NSWindowMiniaturizeButton NSWindowMiniaturizeButton;
-alias NSWindowButton.NSWindowZoomButton NSWindowZoomButton;
-alias NSWindowButton.NSWindowToolbarButton NSWindowToolbarButton;
-alias NSWindowButton.NSWindowDocumentIconButton NSWindowDocumentIconButton;
+ alias NSWindowButton.NSWindowCloseButton NSWindowCloseButton;
+ alias NSWindowButton.NSWindowMiniaturizeButton NSWindowMiniaturizeButton;
+ alias NSWindowButton.NSWindowZoomButton NSWindowZoomButton;
+ alias NSWindowButton.NSWindowToolbarButton NSWindowToolbarButton;
+ alias NSWindowButton.NSWindowDocumentIconButton NSWindowDocumentIconButton;
-enum
-{
+ enum
+ {
NSBorderlessWindowMask = 0,
NSTitledWindowMask = 1 << 0,
NSClosableWindowMask = 1 << 1,
NSMiniaturizableWindowMask = 1 << 2,
NSResizableWindowMask = 1 << 3,
NSTexturedBackgroundWindowMask = 1 << 8
+ }
}
+
public class NSWindow : NSResponder
{
@@ -269,7 +273,7 @@
public NSPoint cascadeTopLeftFromPoint (NSPoint topLeftPoint)
{
NSPoint result;
- OS.objc_msgSend_struct(&result, this.id_, OS.sel_cascadeTopLeftFromPoint_1, &topLeftPoint);
+ OS.objc_msgSend_struct(&result, this.id_, OS.sel_cascadeTopLeftFromPoint_1, topLeftPoint);
return result;
}
@@ -364,7 +368,7 @@
public NSPoint convertScreenToBase (NSPoint aPoint)
{
NSPoint result;
- OS.objc_msgSend_struct(&result, this.id_, OS.sel_convertScreenToBase_1, &aPoint);
+ OS.objc_msgSend_struct(&result, this.id_, OS.sel_convertScreenToBase_1, aPoint);
return result;
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/OS.d
--- a/dwt/internal/cocoa/OS.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/OS.d Fri Oct 10 12:29:48 2008 +0200
@@ -29,13 +29,14 @@
static import dwt.internal.objc.appkit.NSAccessibility;
static import dwt.internal.objc.appkit.NSAttributedString;
static import dwt.internal.objc.appkit.NSGraphics;
-static import dwt.internal.objc.appkit.NSScreen;
static import dwt.internal.objc.coregraphics.CGRemoteOperation;
static import dwt.internal.objc.foundation.NSGeometry;
static import dwt.internal.objc.foundation.NSHFSFileTypes;
static import dwt.internal.objc.foundation.NSRunLoop;
static import dwt.internal.objc.runtime;
+import mambo.io;
+
private alias dwt.internal.objc.runtime.objc_object objc_object;
struct ClassData
@@ -63,7 +64,7 @@
static this ()
{
int[1] response;
- OS.Gestalt(OS.gestaltSystemVersion, response);
+ OS.Gestalt(OS.gestaltSystemVersion, response.ptr);
VERSION = response[0] & 0xffff;
OS.sel_sendSelection = OS.sel_registerName("sendSelection");
@@ -79,6 +80,9 @@
foreach (data ; selectorData)
*data.var = sel_registerName(data.arg);
+
+ OS.NSDefaultRunLoopMode = new NSString(OS.FuncNSDefaultRunLoopMode());
+ OS.NSBackgroundColorAttributeName = new NSString(OS.FuncNSBackgroundColorAttributeName());
}
//TODO - don't hard code
@@ -99,9 +103,49 @@
public static const String sel_drawAtPoint_;
public static const String sel_timerProc_1;
- Object JNIGetObject(NSInteger globalRef)
+ private static Object[] globalRefs;
+
+ static Object JNIGetObject (NSInteger globalRef)
+ {
+ println("OS->JNIGetObject->globalRef=", globalRef);
+ auto o = new Object;
+ o = cast(Object) globalRef;
+ return o;
+ //return globalRefs[globalRef - 1];
+ }
+
+ static NSInteger NewGlobalRef (Object object)
+ {
+ globalRefs ~= object;
+ return globalRefs.length;
+ }
+
+ static void DeleteGlobalRef (NSInteger globalRef)
{
- return cast(Object) globalRef;
+ globalRefs = globalRefs[0 .. remove!(Object)(globalRefs, globalRef - 1)];
+ }
+
+ static size_t remove (T) (T[] arr, size_t index)
+ {
+ void exch (size_t p1, size_t p2)
+ {
+ T t = arr[p1];
+ arr[p1] = arr[p2];
+ arr[p2] = t;
+ }
+
+ size_t cnt = 0;
+
+ for (size_t pos = 0, len = arr.length; pos < len; ++pos)
+ {
+ if (pos == index)
+ ++cnt;
+
+ else
+ exch(pos, pos - cnt);
+ }
+
+ return arr.length - cnt;
}
alias dwt.internal.c.carboncore.Gestalt.Gestalt Gestalt;
@@ -142,6 +186,7 @@
/** objc runtime */
static alias dwt.internal.objc.runtime.objc_registerClassPair objc_registerClassPair;
+ alias dwt.internal.objc.runtime.class_addIvar class_addIvar;
alias dwt.internal.objc.runtime.class_addMethod class_addMethod;
alias dwt.internal.objc.runtime.objc_allocateClassPair objc_allocateClassPair;
alias dwt.internal.objc.runtime.objc_getClass objc_getClass;
@@ -157,8 +202,8 @@
version (X86)
alias dwt.internal.objc.runtime.objc_msgSend_fpret objc_msgSend_fpret;
-
- alias dwt.internal.objc.runtime.drawRect_1CALLBACK drawRect_1CALLBACK;
+
+ alias dwt.internal.objc.runtime.drawRect_CALLBACK drawRect_CALLBACK;
/** Classes */
public static /*const*/ id class_NSScanner;
@@ -14646,12 +14691,12 @@
public static const int NSScrollerArrowsMinEnd = 1;
public static const int NSScrollerArrowsNone = 2;
public static const int NSScrollerDecrementArrow = 1;
- public static const int NSScrollerDecrementLine = 4;
- public static const int NSScrollerDecrementPage = 1;
+// public static const int NSScrollerDecrementLine = 4;
+// public static const int NSScrollerDecrementPage = 1;
public static const int NSScrollerIncrementArrow = 0;
- public static const int NSScrollerIncrementLine = 5;
- public static const int NSScrollerIncrementPage = 3;
- public static const int NSScrollerKnob = 2;
+// public static const int NSScrollerIncrementLine = 5;
+// public static const int NSScrollerIncrementPage = 3;
+// public static const int NSScrollerKnob = 2;
public static const int NSScrollerKnobSlot = 6;
public static const int NSScrollerNoPart = 0;
public static const int NSSearchFieldClearRecentsMenuItemTag = 1002;
@@ -15988,7 +16033,8 @@
// public static const native int NSAttachmentAttributeName();
// public static const native int NSAttributedStringBinding();
// public static const native int NSAuthorDocumentAttribute();
- alias dwt.internal.objc.appkit.NSAttributedString.NSBackgroundColorAttributeName NSBackgroundColorAttributeName;
+ public static const NSString NSBackgroundColorAttributeName;
+ alias dwt.internal.objc.appkit.NSAttributedString.NSBackgroundColorAttributeName FuncNSBackgroundColorAttributeName;
// public static const native int NSBackgroundColorDocumentAttribute();
// public static const native int NSBadBitmapParametersException();
// public static const native int NSBadComparisonException();
@@ -16060,7 +16106,7 @@
// public static const native int NSDeviceIsPrinter();
// public static const native int NSDeviceIsScreen();
alias dwt.internal.objc.appkit.NSGraphics.NSDeviceRGBColorSpace NSDeviceRGBColorSpace;
- alias dwt.internal.objc.appkit.NSScreen.NSDeviceResolution NSDeviceResolution;
+ alias dwt.internal.objc.appkit.NSGraphics.NSDeviceResolution NSDeviceResolution;
// public static const native int NSDeviceSize();
// public static const native int NSDeviceWhiteColorSpace();
// public static const native int NSDirectoryFileType();
@@ -16590,7 +16636,8 @@
// public static const native int NSDecimalNumberExactnessException();
// public static const native int NSDecimalNumberOverflowException();
// public static const native int NSDecimalNumberUnderflowException();
- alias dwt.internal.objc.foundation.NSRunLoop.NSDefaultRunLoopMode NSDefaultRunLoopMode;
+ public static const NSString NSDefaultRunLoopMode;
+ alias dwt.internal.objc.foundation.NSRunLoop.NSDefaultRunLoopMode FuncNSDefaultRunLoopMode;
// public static const native int NSDestinationInvalidException();
// public static const native int NSDidBecomeSingleThreadedNotification();
// public static const native int NSDistinctUnionOfArraysKeyValueOperator();
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTBox.d
--- a/dwt/internal/cocoa/SWTBox.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTBox.d Fri Oct 10 12:29:48 2008 +0200
@@ -19,6 +19,6 @@
public class SWTBox : NSBox {
public void setTag (NSInteger tag) {
- OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+ OS.objc_msgSend(id_, OS.sel_setTag_1, tag);
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTComboBox.d
--- a/dwt/internal/cocoa/SWTComboBox.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTComboBox.d Fri Oct 10 12:29:48 2008 +0200
@@ -13,7 +13,6 @@
*******************************************************************************/
module dwt.internal.cocoa.SWTComboBox;
-import dwt.dwthelper.utils;
import dwt.internal.cocoa.NSComboBox;
public class SWTComboBox : NSComboBox {
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTDatePicker.d
--- a/dwt/internal/cocoa/SWTDatePicker.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTDatePicker.d Fri Oct 10 12:29:48 2008 +0200
@@ -13,7 +13,6 @@
*******************************************************************************/
module dwt.internal.cocoa.SWTDatePicker;
-import dwt.dwthelper.utils;
import dwt.internal.cocoa.NSDatePicker;
public class SWTDatePicker : NSDatePicker {
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTImageView.d
--- a/dwt/internal/cocoa/SWTImageView.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTImageView.d Fri Oct 10 12:29:48 2008 +0200
@@ -13,7 +13,6 @@
*******************************************************************************/
module dwt.internal.cocoa.SWTImageView;
-import dwt.dwthelper.utils;
import dwt.internal.cocoa.NSImageView;
public class SWTImageView : NSImageView {
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTMenu.d
--- a/dwt/internal/cocoa/SWTMenu.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTMenu.d Fri Oct 10 12:29:48 2008 +0200
@@ -11,6 +11,6 @@
public class SWTMenu : NSMenu {
public void setTag (NSInteger tag) {
- OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+ OS.objc_msgSend(id_, OS.sel_setTag_1, tag);
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTPanelDelegate.d
--- a/dwt/internal/cocoa/SWTPanelDelegate.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTPanelDelegate.d Fri Oct 10 12:29:48 2008 +0200
@@ -29,11 +29,11 @@
}
public NSInteger tag () {
- return cast(NSInteger) OS.objc_msgSend(id, OS.sel_tag);
+ return cast(NSInteger) OS.objc_msgSend(id_, OS.sel_tag);
}
public void setTag (NSInteger tag) {
- OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+ OS.objc_msgSend(id_, OS.sel_setTag_1, tag);
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTProgressIndicator.d
--- a/dwt/internal/cocoa/SWTProgressIndicator.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTProgressIndicator.d Fri Oct 10 12:29:48 2008 +0200
@@ -20,6 +20,6 @@
public class SWTProgressIndicator : NSProgressIndicator {
public void setTag (NSInteger tag) {
- OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+ OS.objc_msgSend(id_, OS.sel_setTag_1, tag);
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTScrollView.d
--- a/dwt/internal/cocoa/SWTScrollView.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTScrollView.d Fri Oct 10 12:29:48 2008 +0200
@@ -29,7 +29,7 @@
}
public void setTag (NSInteger tag) {
- OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+ OS.objc_msgSend(id_, OS.sel_setTag_1, tag);
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTTabView.d
--- a/dwt/internal/cocoa/SWTTabView.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTTabView.d Fri Oct 10 12:29:48 2008 +0200
@@ -29,6 +29,6 @@
}
public void setTag (NSInteger tag) {
- OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+ OS.objc_msgSend(id_, OS.sel_setTag_1, tag);
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTTextView.d
--- a/dwt/internal/cocoa/SWTTextView.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTTextView.d Fri Oct 10 12:29:48 2008 +0200
@@ -29,6 +29,6 @@
}
public void setTag (NSInteger tag) {
- OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+ OS.objc_msgSend(id_, OS.sel_setTag_1, tag);
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTTreeItem.d
--- a/dwt/internal/cocoa/SWTTreeItem.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTTreeItem.d Fri Oct 10 12:29:48 2008 +0200
@@ -15,14 +15,15 @@
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
public class SWTTreeItem : NSObject {
public NSInteger tag () {
- return cast(NSInteger) OS.objc_msgSend(id, OS.sel_tag);
+ return cast(NSInteger) OS.objc_msgSend(id_, OS.sel_tag);
}
public void setTag (NSInteger tag) {
- OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+ OS.objc_msgSend(id_, OS.sel_setTag_1, tag);
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTView.d
--- a/dwt/internal/cocoa/SWTView.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTView.d Fri Oct 10 12:29:48 2008 +0200
@@ -29,6 +29,6 @@
}
public void setTag (NSInteger tag) {
- OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+ OS.objc_msgSend(id_, OS.sel_setTag_1, tag);
}
}
\ No newline at end of file
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTWebViewDelegate.d
--- a/dwt/internal/cocoa/SWTWebViewDelegate.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTWebViewDelegate.d Fri Oct 10 12:29:48 2008 +0200
@@ -15,10 +15,11 @@
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
public class SWTWebViewDelegate : NSObject {
public void setTag (NSInteger tag) {
- OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+ OS.objc_msgSend(id_, OS.sel_setTag_1, tag);
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTWindow.d
--- a/dwt/internal/cocoa/SWTWindow.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTWindow.d Fri Oct 10 12:29:48 2008 +0200
@@ -20,6 +20,6 @@
public class SWTWindow : NSWindow {
public void setTag (NSInteger tag) {
- OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+ OS.objc_msgSend(id_, OS.sel_setTag_1, tag);
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/SWTWindowDelegate.d
--- a/dwt/internal/cocoa/SWTWindowDelegate.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/SWTWindowDelegate.d Fri Oct 10 12:29:48 2008 +0200
@@ -15,6 +15,7 @@
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;
public class SWTWindowDelegate : NSObject {
@@ -28,11 +29,11 @@
}
public NSInteger tag () {
- return cast(NSInteger) OS.objc_msgSend(id, OS.sel_tag);
+ return cast(NSInteger) OS.objc_msgSend(id_, OS.sel_tag);
}
public void setTag (NSInteger tag) {
- OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+ OS.objc_msgSend(id_, OS.sel_setTag_1, tag);
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/WebDataSource.d
--- a/dwt/internal/cocoa/WebDataSource.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/WebDataSource.d Fri Oct 10 12:29:48 2008 +0200
@@ -25,7 +25,7 @@
//}
public NSData data() {
- int result = OS.objc_msgSend(this.id, OS.sel_data);
+ int result = OS.objc_msgSend(this.id_, OS.sel_data);
return result !is 0 ? new NSData(result) : null;
}
@@ -40,7 +40,7 @@
//}
public bool isLoading() {
- return OS.objc_msgSend(this.id, OS.sel_isLoading) !is 0;
+ return OS.objc_msgSend(this.id_, OS.sel_isLoading) !is 0;
}
//public WebResource mainResource() {
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/cocoa/gl.d
--- a/dwt/internal/cocoa/gl.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/gl.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,6 +7,8 @@
*/
module dwt.internal.cocoa.gl;
+extern (C):
+
alias uint GLenum;
alias ubyte GLboolean;
alias uint GLbitfield;
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/objc/appkit/AppKit.d
--- a/dwt/internal/objc/appkit/AppKit.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/objc/appkit/AppKit.d Fri Oct 10 12:29:48 2008 +0200
@@ -12,4 +12,3 @@
import dwt.internal.objc.appkit.NSAccessibility;
import dwt.internal.objc.appkit.NSAttributedString;
import dwt.internal.objc.appkit.NSGraphics;
-import dwt.internal.objc.appkit.NSScreen;
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/objc/appkit/NSAccessibility.d
--- a/dwt/internal/objc/appkit/NSAccessibility.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/objc/appkit/NSAccessibility.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,15 +7,16 @@
*/
module dwt.internal.objc.appkit.NSAccessibility;
-import dwt.internal.cocoa.NSString;
import bindings = dwt.internal.objc.appkit.bindings;
+import dwt.internal.objc.runtime;
+
-NSString NSAccessibilityPositionAttribute ()
+id NSAccessibilityPositionAttribute ()
{
- return new NSString(bindings.DCB_NSAccessibilityPositionAttribute());
+ return bindings.DCB_NSAccessibilityPositionAttribute;
}
-NSString NSAccessibilitySizeAttribute ()
+id NSAccessibilitySizeAttribute ()
{
- return new NSString(bindings.DCB_NSAccessibilitySizeAttribute());
+ return bindings.DCB_NSAccessibilitySizeAttribute;
}
\ No newline at end of file
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/objc/appkit/NSAttributedString.d
--- a/dwt/internal/objc/appkit/NSAttributedString.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/objc/appkit/NSAttributedString.d Fri Oct 10 12:29:48 2008 +0200
@@ -9,53 +9,54 @@
import dwt.internal.cocoa.NSString;
import bindings = dwt.internal.objc.appkit.bindings;
+import dwt.internal.objc.runtime;
-NSString NSBackgroundColorAttributeName ()
+id NSBackgroundColorAttributeName ()
{
- return new NSString(bindings.DCB_NSBackgroundColorAttributeName());
+ return bindings.DCB_NSBackgroundColorAttributeName;
}
NSString NSBaselineOffsetAttributeName ()
{
- return new NSString(bindings.DCB_NSBaselineOffsetAttributeName());
+ return new NSString(bindings.DCB_NSBaselineOffsetAttributeName);
}
NSString NSFontAttributeName ()
{
- return new NSString(bindings.DCB_NSFontAttributeName());
+ return new NSString(bindings.DCB_NSFontAttributeName);
}
NSString NSForegroundColorAttributeName ()
{
- return new NSString(bindings.DCB_NSForegroundColorAttributeName());
+ return new NSString(bindings.DCB_NSForegroundColorAttributeName);
}
NSString NSLinkAttributeName ()
{
- return new NSString(bindings.DCB_NSLinkAttributeName());
+ return new NSString(bindings.DCB_NSLinkAttributeName);
}
NSString NSParagraphStyleAttributeName ()
{
- return new NSString(bindings.DCB_NSParagraphStyleAttributeName());
+ return new NSString(bindings.DCB_NSParagraphStyleAttributeName);
}
NSString NSStrikethroughColorAttributeName ()
{
- return new NSString(bindings.DCB_NSStrikethroughColorAttributeName());
+ return new NSString(bindings.DCB_NSStrikethroughColorAttributeName);
}
NSString NSStrikethroughStyleAttributeName ()
{
- return new NSString(bindings.DCB_NSStrikethroughStyleAttributeName());
+ return new NSString(bindings.DCB_NSStrikethroughStyleAttributeName);
}
NSString NSUnderlineColorAttributeName ()
{
- return new NSString(bindings.DCB_NSUnderlineColorAttributeName());
+ return new NSString(bindings.DCB_NSUnderlineColorAttributeName);
}
NSString NSUnderlineStyleAttributeName ()
{
- return new NSString(bindings.DCB_NSUnderlineStyleAttributeName());
+ return new NSString(bindings.DCB_NSUnderlineStyleAttributeName);
}
\ No newline at end of file
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/objc/appkit/NSGraphics.d
--- a/dwt/internal/objc/appkit/NSGraphics.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/objc/appkit/NSGraphics.d Fri Oct 10 12:29:48 2008 +0200
@@ -8,11 +8,17 @@
module dwt.internal.objc.appkit.NSGraphics;
import dwt.internal.cocoa.NSString;
-import bindings = dwt.internal.objc.appkit.bindings : NSBitsPerPixelFromDepth, DCB_NSDeviceRGBColorSpace;
+import bindings = dwt.internal.objc.appkit.bindings : NSBitsPerPixelFromDepth, DCB_NSDeviceResolution, DCB_NSDeviceRGBColorSpace;
+import dwt.internal.objc.runtime;
alias bindings.NSBitsPerPixelFromDepth NSBitsPerPixelFromDepth;
NSString NSDeviceRGBColorSpace ()
{
return new NSString(bindings.DCB_NSDeviceRGBColorSpace());
+}
+
+id NSDeviceResolution ()
+{
+ return bindings.DCB_NSDeviceResolution;
}
\ No newline at end of file
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/objc/appkit/NSScreen.d
--- a/dwt/internal/objc/appkit/NSScreen.d Tue Oct 07 12:56:18 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: 2008
- * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
- *
- */
-module dwt.internal.objc.appkit.NSScreen;
-
-import dwt.internal.cocoa.NSString;
-import bindings = dwt.internal.objc.appkit.bindings : DCB_NSDeviceResolution;
-
-NSString NSDeviceResolution ()
-{
- return new NSString(bindings.DCB_NSDeviceResolution());
-}
\ No newline at end of file
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/objc/foundation/NSRunLoop.d
--- a/dwt/internal/objc/foundation/NSRunLoop.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/objc/foundation/NSRunLoop.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,12 +7,10 @@
*/
module dwt.internal.objc.foundation.NSRunLoop;
-import dwt.internal.cocoa.NSString;
import dwt.internal.objc.foundation.bindings;
-
-const NSString NSDefaultRunLoopMode;
+import dwt.internal.objc.runtime;
-static this ()
+id NSDefaultRunLoopMode ()
{
- NSDefaultRunLoopMode = new NSString(DCB_NSDefaultRunLoopMode());
+ return DCB_NSDefaultRunLoopMode;
}
\ No newline at end of file
diff -r db5a898b2119 -r 642f460a0908 dwt/internal/objc/runtime.d
--- a/dwt/internal/objc/runtime.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/objc/runtime.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,7 +7,7 @@
*/
module dwt.internal.objc.runtime;
-import tango.stdc.stringz : fromStringz, toStringz;
+import tango.stdc.stringz;
import dwt.dwthelper.utils : String;
import dwt.internal.cocoa.NSPoint;
@@ -17,7 +17,8 @@
static import dwt.internal.objc.bindings;
-
+extern (C)
+{
alias objc_ivar* Ivar;
alias objc_method* Method;
alias objc_object Protocol;
@@ -29,21 +30,21 @@
alias extern (C) id function(id, SEL, ...) IMP;
struct objc_object
-{
+ {
Class isa;
-}
+ }
struct objc_super
-{
+ {
id receiver;
Class clazz;
// for dwt compatibility
alias clazz cls;
-}
+ }
struct objc_class
-{
+ {
Class isa;
Class super_class;
const char* name;
@@ -54,65 +55,67 @@
objc_method_list** methodLists;
objc_cache* cache;
objc_protocol_list* protocols;
-}
+ }
struct objc_ivar
-{
+ {
char* ivar_name;
char* ivar_type;
int ivar_offset;
-
+
version (X86_64)
- int space;
-}
+ int space;
+ }
struct objc_ivar_list
-{
+ {
int ivar_count;
-
+
version (X86_64)
- int space;
-
+ int space;
+
/* variable length structure */
objc_ivar ivar_list[1];
-}
+ }
struct objc_method
-{
+ {
SEL method_name;
char* method_types;
IMP method_imp;
-}
+ }
struct objc_method_list
-{
+ {
objc_method_list* obsolete;
-
+
int method_count;
-
+
version (X86_64)
- int space;
-
+ int space;
+
/* variable length structure */
objc_method method_list[1];
-}
+ }
struct objc_cache
-{
+ {
uint mask /* total = mask + 1 */;
uint occupied;
Method buckets[1];
-}
+ }
struct objc_protocol_list
-{
+ {
objc_protocol_list* next;
long count;
Protocol* list[1];
+ }
}
+
alias dwt.internal.objc.bindings.objc_registerClassPair objc_registerClassPair;
bool class_addIvar (Class cls, String name, size_t size, byte alignment, String types)
@@ -165,11 +168,9 @@
return dwt.internal.objc.bindings.objc_msgSend(theReceiver, theSelector.ptr, args);
}
-/// dummy function for now
-int objc_msgSend_struct (T, ARGS...)(T* result, id theReceiver, String theSelector, ARGS args)
+void objc_msgSend_struct (T, ARGS...)(T* result, id theReceiver, String theSelector, ARGS args)
{
- //result = *cast(T) dwt.internal.objc.bindings.objc_msgSend(theReceiver, theSelector.ptr, args);
- return 0;
+ result = cast(T*) dwt.internal.objc.bindings.objc_msgSend(theReceiver, theSelector.ptr, args);
}
void objc_msgSend_stret (T, ARGS...)(T* stretAddr, id theReceiver, String theSelector, ARGS args)
@@ -193,17 +194,17 @@
// os_custom
extern (C):
-alias void function (id, SEL, NSRect) funcPtr;
-static IMP drawRect_1CALLBACKK;
+//alias void function (id, SEL, NSRect*) funcPtr;
+static IMP drawRect_1CALLBACK;
private void drawRect(id obj, SEL sel, NSRect rect)
{
- return cast(funcPtr) drawRect_1CALLBACKK(obj, sel, &rect);
+ return cast(IMP) drawRect_1CALLBACK(obj, sel, &rect);
}
-funcPtr drawRect_1CALLBACK (IMP func)
+IMP drawRect_CALLBACK (IMP func)
{
- drawRect_1CALLBACKK = func;
- return &drawRect;
+ drawRect_1CALLBACK = func;
+ return cast(IMP) &drawRect;
}
\ No newline at end of file
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Button.d
--- a/dwt/widgets/Button.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Button.d Fri Oct 10 12:29:48 2008 +0200
@@ -33,7 +33,9 @@
import dwt.dwthelper.utils;
import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSCell;
import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSText;
import dwt.widgets.Composite;
import dwt.widgets.Control;
import dwt.widgets.Decorations;
@@ -167,13 +169,13 @@
if (font !is null) {
dict.setObject(font.handle, OS.NSFontAttributeName());
}
- int alignment;
+ NSTextAlignment alignment;
if ((style & DWT.CENTER) !is 0) {
- alignment = OS.NSCenterTextAlignment;
+ alignment = NSCenterTextAlignment;
} else if ((style & DWT.LEFT) !is 0) {
- alignment = OS.NSLeftTextAlignment;
+ alignment = NSLeftTextAlignment;
} else {
- alignment = OS.NSRightTextAlignment;
+ alignment = NSRightTextAlignment;
}
NSMutableParagraphStyle pStyle = cast(NSMutableParagraphStyle)(new NSMutableParagraphStyle()).alloc().init();
pStyle.autorelease();
@@ -191,23 +193,23 @@
void createHandle () {
NSButton widget = cast(NSButton)(new SWTButton()).alloc();
widget.initWithFrame(NSRect());
- int type = OS.NSMomentaryPushButton;
+ NSButtonType type = NSMomentaryPushButton;
if ((style & DWT.PUSH) !is 0) {
- widget.setBezelStyle(OS.NSRoundedBezelStyle);
+ widget.setBezelStyle(NSRoundedBezelStyle);
} else if ((style & DWT.CHECK) !is 0) {
- type = OS.NSSwitchButton;
+ type = NSSwitchButton;
widget.setAllowsMixedState (true);
} else if ((style & DWT.RADIO) !is 0) {
- type = OS.NSRadioButton;
+ type = NSRadioButton;
} else if ((style & DWT.TOGGLE) !is 0) {
- type = OS.NSPushOnPushOffButton;
- widget.setBezelStyle(OS.NSRegularSquareBezelStyle);
+ type = NSPushOnPushOffButton;
+ widget.setBezelStyle(NSRegularSquareBezelStyle);
} else if ((style & DWT.ARROW) !is 0) {
- widget.setBezelStyle(OS.NSRoundedDisclosureBezelStyle);
+ widget.setBezelStyle(NSRoundedDisclosureBezelStyle);
}
widget.setButtonType(type);
widget.setTitle(NSString.stringWith(""));
- widget.setImagePosition(OS.NSImageLeft);
+ widget.setImagePosition(NSImageLeft);
widget.setTarget(widget);
widget.setAction(OS.sel_sendSelection);
widget.setTag(jniRef);
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Canvas.d
--- a/dwt/widgets/Canvas.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Canvas.d Fri Oct 10 12:29:48 2008 +0200
@@ -29,6 +29,7 @@
import dwt.internal.cocoa.OS;
import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSImage;
import dwt.widgets.Caret;
import dwt.widgets.Composite;
import dwt.widgets.Control;
@@ -136,7 +137,7 @@
}
}
-void drawRect(int id, NSRect rect) {
+void drawRect(objc.id id, NSRect rect) {
super.drawRect(id, rect);
if (caret is null) return;
if (caret.isShowing) {
@@ -151,10 +152,10 @@
NSPoint point = NSPoint();
point.x = caret.x;
point.y = caret.y;
- image.handle.drawAtPoint(point, rect, OS.NSCompositeXOR, 1);
+ image.handle.drawAtPoint(point, rect, NSCompositeXOR, 1);
} else {
context.saveGraphicsState();
- context.setCompositingOperation(OS.NSCompositeXOR);
+ context.setCompositingOperation(NSCompositeXOR);
NSRect drawRect = NSRect();
drawRect.x = caret.x;
drawRect.y = caret.y;
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/ColorDialog.d
--- a/dwt/widgets/ColorDialog.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/ColorDialog.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,11 +7,12 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ *
+ * Port to the D programming language:
+ * Jacob Carlborg
*******************************************************************************/
module dwt.widgets.ColorDialog;
-import dwt.dwthelper.utils;
-
import dwt.DWT;
import dwt.DWTException;
@@ -24,6 +25,12 @@
import dwt.internal.cocoa.OS;
import dwt.internal.cocoa.SWTPanelDelegate;
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSInteger;
+import dwt.widgets.Dialog;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+
/**
* Instances of this class allow the user to select a color
* from a predefined set of available colors.
@@ -41,126 +48,126 @@
public class ColorDialog : Dialog {
RGB rgb;
-/**
- * Constructs a new instance of this class given only its parent.
- *
- * @param parent a composite control which will be the parent of the new instance
- *
- * @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the parent is null
- *
- * @exception DWTException
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- * - ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- *
- *
- * @see DWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public this(Shell parent) {
- this(parent, DWT.APPLICATION_MODAL);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- *
- * The style value is either one of the style constants defined in
- * class DWT
which is applicable to instances of this
- * class, or must be built by bitwise OR'ing together
- * (that is, using the int
"|" operator) two or more
- * of those DWT
style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- *
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the parent is null
- *
- * @exception DWTException
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- * - ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- *
- *
- * @see DWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public this(Shell parent, int style) {
- super(parent, style);
- checkSubclass ();
-}
-
-void changeColor(int sender) {
- //TODO
-}
-
-/**
- * Returns the currently selected color in the receiver.
- *
- * @return the RGB value for the selected color, may be null
- *
- * @see PaletteData#getRGBs
- */
-public RGB getRGB() {
- return rgb;
-}
-
-/**
- * Makes the receiver visible and brings it to the front
- * of the display.
- *
- * @return the selected color, or null if the dialog was
- * cancelled, no color was selected, or an error
- * occurred
- *
- * @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
- *
- */
-public RGB open() {
- NSColorPanel panel = NSColorPanel.sharedColorPanel();
- if (rgb !is null) {
- NSColor color = NSColor.colorWithDeviceRed(rgb.red / 255f, rgb.green / 255f, rgb.blue / 255f, 1);
- panel.setColor(color);
+ /**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a composite control which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the parent is null
+ *
+ * @exception DWTException
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
+ * - ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
+ *
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+ public this(Shell parent) {
+ this(parent, DWT.APPLICATION_MODAL);
+ }
+
+ /**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ *
+ * The style value is either one of the style constants defined in
+ * class DWT
which is applicable to instances of this
+ * class, or must be built by bitwise OR'ing together
+ * (that is, using the int
"|" operator) two or more
+ * of those DWT
style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ *
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the parent is null
+ *
+ * @exception DWTException
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
+ * - ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
+ *
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+ public this(Shell parent, int style) {
+ super(parent, style);
+ checkSubclass ();
+ }
+
+ void changeColor(int sender) {
+ //TODO
}
- SWTPanelDelegate delegate = cast(SWTPanelDelegate)new SWTPanelDelegate().alloc().init();
- int jniRef = OS.NewGlobalRef(this);
- if (jniRef is 0) DWT.error(DWT.ERROR_NO_HANDLES);
- delegate.setTag(jniRef);
- panel.setDelegate(delegate);
- rgb = null;
- panel.orderFront(null);
- NSApplication.sharedApplication().runModalForWindow_(panel);
- panel.setDelegate(null);
- delegate.release();
- OS.DeleteGlobalRef(jniRef);
- NSColor color = panel.color();
- if (color !is null) {
- color = color.colorUsingColorSpaceName_(NSString.stringWith("NSCalibratedRGBColorSpace"));
- rgb = new RGB(cast(int)(color.redComponent() * 255), cast(int)(color.greenComponent() * 255), cast(int)(color.blueComponent() * 255));
+
+ /**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color, may be null
+ *
+ * @see PaletteData#getRGBs
+ */
+ public RGB getRGB() {
+ return rgb;
}
- return rgb;
-}
-
-/**
- * Sets the receiver's selected color to be the argument.
- *
- * @param rgb the new RGB value for the selected color, may be
- * null to let the platform select a default when
- * open() is called
- * @see PaletteData#getRGBs
- */
-public void setRGB(RGB rgb) {
- this.rgb = rgb;
-}
-
-void windowWillClose(int sender) {
- NSApplication.sharedApplication().stop(null);
-}
-}
+
+ /**
+ * Makes the receiver visible and brings it to the front
+ * of the display.
+ *
+ * @return the selected color, or null if the dialog was
+ * cancelled, no color was selected, or an error
+ * occurred
+ *
+ * @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
+ *
+ */
+ public RGB open() {
+ NSColorPanel panel = NSColorPanel.sharedColorPanel();
+ if (rgb !is null) {
+ NSColor color = NSColor.colorWithDeviceRed(rgb.red / 255f, rgb.green / 255f, rgb.blue / 255f, 1);
+ panel.setColor(color);
+ }
+ SWTPanelDelegate delegate_ = cast(SWTPanelDelegate)(new SWTPanelDelegate()).alloc().init();
+ NSInteger jniRef = OS.NewGlobalRef(this);
+ if (jniRef is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+ delegate_.setTag(jniRef);
+ panel.setDelegate(delegate_);
+ rgb = null;
+ panel.orderFront(null);
+ NSApplication.sharedApplication().runModalForWindow_(panel);
+ panel.setDelegate(null);
+ delegate_.release();
+ OS.DeleteGlobalRef(jniRef);
+ NSColor color = panel.color();
+ if (color !is null) {
+ color = color.colorUsingColorSpaceName_(NSString.stringWith("NSCalibratedRGBColorSpace"));
+ rgb = new RGB(cast(int)(color.redComponent() * 255), cast(int)(color.greenComponent() * 255), cast(int)(color.blueComponent() * 255));
+ }
+ return rgb;
+ }
+
+ /**
+ * Sets the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color, may be
+ * null to let the platform select a default when
+ * open() is called
+ * @see PaletteData#getRGBs
+ */
+ public void setRGB(RGB rgb) {
+ this.rgb = rgb;
+ }
+
+ void windowWillClose(int sender) {
+ NSApplication.sharedApplication().stop(null);
+ }
+ }
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Composite.d
--- a/dwt/widgets/Composite.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Composite.d Fri Oct 10 12:29:48 2008 +0200
@@ -39,7 +39,6 @@
import dwt.widgets.Shell;
import dwt.widgets.Widget;
-
/**
* Instances of this class are controls which are capable
* of containing other controls.
@@ -268,7 +267,7 @@
scrollWidget.setDrawsBackground(false);
if ((style & DWT.H_SCROLL) !is 0) scrollWidget.setHasHorizontalScroller(true);
if ((style & DWT.V_SCROLL) !is 0) scrollWidget.setHasVerticalScroller(true);
- scrollWidget.setBorderType(hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder);
+ scrollWidget.setBorderType(hasBorder() ? NSBezelBorder : NSNoBorder);
scrollWidget.setTag(jniRef);
scrollView = scrollWidget;
rect.width = rect.height = 100000;
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Control.d
--- a/dwt/widgets/Control.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Control.d Fri Oct 10 12:29:48 2008 +0200
@@ -91,6 +91,9 @@
*
*/
public abstract class Control : Widget , Drawable {
+
+ alias Widget.setInputState setInputState;
+
/**
* the handle to the OS resource
* (Warning: This field is platform dependent)
@@ -160,7 +163,7 @@
objc_super super_struct = objc_super();
super_struct.receiver = view.id_;
super_struct.cls = cast(objc.Class) OS.objc_msgSend(view.id_, OS.sel_superclass);
- return OS.objc_msgSendSuper(super_struct, OS.sel_acceptsFirstResponder) !is null;
+ return OS.objc_msgSendSuper(&super_struct, OS.sel_acceptsFirstResponder) !is null;
}
bool becomeFirstResponder () {
@@ -168,8 +171,8 @@
sendEvent (DWT.FocusIn);
objc_super super_struct = objc_super();
super_struct.receiver = view.id_;
- super_struct.cls = OS.objc_msgSend(view.id_, OS.sel_superclass);
- return OS.objc_msgSendSuper(super_struct, OS.sel_becomeFirstResponder) !is null;
+ super_struct.cls = cast(objc.Class) OS.objc_msgSend(view.id_, OS.sel_superclass);
+ return OS.objc_msgSendSuper(&super_struct, OS.sel_becomeFirstResponder) !is null;
}
bool resignFirstResponder () {
@@ -177,8 +180,8 @@
sendEvent (DWT.FocusOut);
objc_super super_struct = objc_super();
super_struct.receiver = view.id_;
- super_struct.cls = OS.objc_msgSend(view.id_, OS.sel_superclass);
- return OS.objc_msgSendSuper(super_struct, OS.sel_resignFirstResponder) !is null;
+ super_struct.cls = cast(objc.Class) OS.objc_msgSend(view.id_, OS.sel_superclass);
+ return OS.objc_msgSendSuper(&super_struct, OS.sel_resignFirstResponder) !is null;
}
/**
@@ -639,7 +642,7 @@
Control[] computeTabList() {
if (isTabGroup()) {
if (getVisible() && getEnabled()) {
- return new Control[] [this];
+ return [this];
}
}
return new Control[0];
@@ -806,13 +809,14 @@
return false;
}
-void drawRect(int id, NSRect rect) {
+void drawRect(objc.id id, NSRect rect) {
super.drawRect(id, rect);
if (!hooks (DWT.Paint) && !filters (DWT.Paint)) return;
/* Send paint event */
GCData data = new GCData ();
- data.paintRect = rect;
+ data.paintRectStruct = rect;
+ data.paintRect = &data.paintRectStruct;
GC gc = GC.cocoa_new (this, data);
Event event = new Event ();
event.gc = gc;
@@ -843,7 +847,7 @@
}
Menu [] findMenus (Control control) {
- if (menu !is null && this !is control) return new Menu [] [menu];
+ if (menu !is null && this !is control) return [menu];
return new Menu [0];
}
@@ -1351,7 +1355,7 @@
* @param hDC the platform specific GC handle
* @param data the platform specific GC data
*/
-public void internal_dispose_GC (int context, GCData data) {
+public void internal_dispose_GC (objc.id context, GCData data) {
checkWidget ();
}
@@ -1492,7 +1496,7 @@
event.x = x;
event.y = y;
sendEvent (DWT.MenuDetect, event);
- if (!event.doit) return 0;
+ if (!event.doit) return null;
Menu menu = getMenu ();
if (menu !is null && !menu.isDisposed ()) {
if (x !is event.x || y !is event.y) {
@@ -1502,8 +1506,8 @@
}
objc_super super_struct = objc_super();
super_struct.receiver = view.id_;
- super_struct.cls = OS.objc_msgSend(view.id_, OS.sel_superclass);
- return OS.objc_msgSendSuper(super_struct, OS.sel_menuForEvent_1, nsEvent);
+ super_struct.cls = cast(objc.Class) OS.objc_msgSend(view.id_, OS.sel_superclass);
+ return OS.objc_msgSendSuper(&super_struct, OS.sel_menuForEvent_1, nsEvent);
}
Decorations menuShell () {
@@ -1574,13 +1578,13 @@
sendEvent (type, event);
}
-void mouseDown(int theEvent) {
+void mouseDown(objc.id theEvent) {
NSEvent nsEvent = new NSEvent (theEvent);
sendMouseEvent (nsEvent, DWT.MouseDown, 1);
}
void mouseDragged(objc.id theEvent) {
- NSEvent nsEvent = new NSEvent (objc.id);
+ NSEvent nsEvent = new NSEvent (theEvent);
sendMouseEvent (nsEvent, DWT.MouseMove, 1);
}
@@ -1614,7 +1618,7 @@
}
setInputState (event, nsEvent, type);
if (!setKeyState(event, type, nsEvent)) return false;
- if (sendKeyEvent (type, event)) {
+ if ((cast(Widget)this).sendKeyEvent (type, event)) {
chars [count++] = chars [i];
}
}
@@ -2525,11 +2529,11 @@
checkWidget();
if (((state & DISABLED) is 0) is enabled) return;
Control control = null;
- bool fixFocus = false;
+ bool fixFocus_ = false;
if (!enabled) {
// if (display.focusEvent !is DWT.FocusOut) {
control = display.getFocusControl ();
- fixFocus = isFocusAncestor (control);
+ fixFocus_ = isFocusAncestor (control);
// }
}
if (enabled) {
@@ -2538,7 +2542,7 @@
state |= DISABLED;
}
enableWidget (enabled);
- if (fixFocus) fixFocus (control);
+ if (fixFocus_) fixFocus (control);
}
/**
@@ -2935,11 +2939,11 @@
* the focus control.
*/
Control control = null;
- bool fixFocus = false;
+ bool fixFocus_ = false;
if (!visible) {
// if (display.focusEvent !is DWT.FocusOut) {
control = display.getFocusControl ();
- fixFocus = isFocusAncestor (control);
+ fixFocus_ = isFocusAncestor (control);
// }
}
topView().setHidden(!visible);
@@ -2952,7 +2956,7 @@
sendEvent (DWT.Hide);
if (isDisposed ()) return;
}
- if (fixFocus) fixFocus (control);
+ if (fixFocus_) fixFocus (control);
}
void setZOrder () {
@@ -2970,7 +2974,7 @@
NSView otherView = control is null ? null : control.topView ();
view.retain();
view.removeFromSuperview();
- parent.contentView().addSubview_positioned_relativeTo_(view, above ? OS.NSWindowAbove : OS.NSWindowBelow, otherView);
+ parent.contentView().addSubview_positioned_relativeTo_(view, above ? NSWindowAbove : NSWindowBelow, otherView);
view.release();
}
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Decorations.d
--- a/dwt/widgets/Decorations.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Decorations.d Fri Oct 10 12:29:48 2008 +0200
@@ -106,7 +106,7 @@
*/
public class Decorations : Canvas {
Image image;
- Image [] images = new Image [0];
+ Image [] images;
Menu menuBar;
String text = "";
bool minimized, maximized;
@@ -157,6 +157,7 @@
*/
public this (Composite parent, int style) {
super (parent, checkStyle (style));
+ images = new Image [0];
}
static int checkStyle (int style) {
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Display.d
--- a/dwt/widgets/Display.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Display.d Fri Oct 10 12:29:48 2008 +0200
@@ -57,7 +57,6 @@
import dwt.internal.cocoa.id;
import tango.core.Thread;
-import tango.stdc.stringz;
import dwt.dwthelper.Runnable;
import dwt.dwthelper.System;
@@ -68,18 +67,23 @@
import objc = dwt.internal.objc.runtime;
import dwt.widgets.Caret;
+import dwt.widgets.ColorDialog;
import dwt.widgets.Control;
import dwt.widgets.Dialog;
import dwt.widgets.Event;
import dwt.widgets.EventTable;
+import dwt.widgets.FontDialog;
import dwt.widgets.Listener;
import dwt.widgets.Menu;
+import dwt.widgets.MenuItem;
import dwt.widgets.Monitor;
import dwt.widgets.Shell;
import dwt.widgets.Synchronizer;
import dwt.widgets.Tray;
import dwt.widgets.Widget;
+import mambo.io;
+
/**
* Instances of this class are responsible for managing the
* connection between DWT and the underlying operating
@@ -192,7 +196,7 @@
/* System Resources */
Image errorImage, infoImage, warningImage;
- Cursor [] cursors = new Cursor [DWT.CURSOR_HAND + 1];
+ Cursor [] cursors;
/* Key Mappings. */
static int [] [] KeyTable = [
@@ -278,7 +282,7 @@
/* Multiple Displays. */
static Display Default;
- static Display [] Displays = new Display [4];
+ static Display [] Displays;
/* Package Name */
static const String PACKAGE_PREFIX = "dwt.widgets.";
@@ -286,7 +290,7 @@
/* Timer */
Runnable timerList [];
NSTimer nsTimers [];
- SWTWindowDelegate timerDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init();
+ SWTWindowDelegate timerDelegate;
SWTApplicationDelegate applicationDelegate;
/* Display Data */
@@ -546,6 +550,31 @@
*/
public this (DeviceData data) {
super (data);
+ cursors = new Cursor [DWT.CURSOR_HAND + 1];
+ Displays = new Display [4];
+ timerDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init();
+
+ caretTimer = new class(currentCaret) Runnable {
+ Caret currentCaret;
+
+ this (Caret currentCaret)
+ {
+ this.currentCaret = currentCaret;
+ }
+
+ public void run () {
+ if (currentCaret !is null) {
+ if (currentCaret is null || currentCaret.isDisposed()) return;
+ if (currentCaret.blinkCaret ()) {
+ int blinkRate = currentCaret.blinkRate;
+ if (blinkRate !is 0) timerExec (blinkRate, this);
+ } else {
+ currentCaret = null;
+ }
+ }
+
+ }
+ };
}
static void checkDisplay (Thread thread, bool multiple) {
@@ -745,7 +774,7 @@
}
}
Runnable [] newDisposeList = new Runnable [disposeList.length + 4];
- System.arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length);
+ SimpleType!(Runnable).arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length);
newDisposeList [disposeList.length] = runnable;
disposeList = newDisposeList;
}
@@ -885,7 +914,7 @@
if (window !is null) {
NSView view = window.contentView();
if (view !is null && view.respondsToSelector(OS.sel_tag)) {
- NSInteger tag = OS.objc_msgSend(view.id_, OS.sel_tag);
+ NSInteger tag = cast(NSInteger) OS.objc_msgSend(view.id_, OS.sel_tag);
if (tag !is -1) {
Object object = OS.JNIGetObject(tag);
if (cast(Shell) object) {
@@ -996,7 +1025,7 @@
*/
public Point [] getCursorSizes () {
checkDevice ();
- return new Point [] [new Point (16, 16)];
+ return [new Point (16, 16)];
}
/**
@@ -1135,7 +1164,7 @@
if (window !is null) {
NSResponder view = window.firstResponder();
if (view !is null && view.respondsToSelector(OS.sel_tag)) {
- NSInteger tag = OS.objc_msgSend(view.id_, OS.sel_tag);
+ NSInteger tag = cast(NSInteger) OS.objc_msgSend(view.id_, OS.sel_tag);
if (tag !is -1) {
Object object = OS.JNIGetObject(tag);
if (cast(Control) object) {
@@ -1150,11 +1179,11 @@
if (view.isKindOfClass(NSText.static_class())) {
NSText text = new NSText(view.id_);
if (text.isFieldEditor()) {
- id delegateId = text.delegatee();
+ id delegateId = text.delegate_();
if (delegateId !is null) {
- NSObject delegatee = new NSObject(delegateId.id_);
- if (delegatee.respondsToSelector(OS.sel_tag)) {
- tag = OS.objc_msgSend(delegatee.id_, OS.sel_tag);
+ NSObject delegate_ = new NSObject(delegateId.id_);
+ if (delegate_.respondsToSelector(OS.sel_tag)) {
+ tag = cast(NSInteger) OS.objc_msgSend(delegate_.id_, OS.sel_tag);
if (tag !is 0 && tag !is -1) {
Object object = OS.JNIGetObject(tag);
if (cast(Control) object) {
@@ -1227,7 +1256,7 @@
*/
public Point [] getIconSizes () {
checkDevice ();
- return new Point [] [
+ return [
new Point (16, 16), new Point (32, 32),
new Point (64, 64), new Point (128, 128)];
}
@@ -1348,7 +1377,7 @@
NSWindow window = new NSWindow(windows.objectAtIndex(i));
NSView view = window.contentView();
if (view !is null) {
- NSInteger jniRef = OS.objc_msgSend(view.id_, OS.sel_tag);
+ NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(view.id_, OS.sel_tag);
if (jniRef !is 0 && jniRef !is -1) {
Object object = OS.JNIGetObject(jniRef);
if (cast(Shell) object) {
@@ -1426,7 +1455,7 @@
NSColor color = null;
switch (id) {
case DWT.COLOR_INFO_FOREGROUND: return super.getSystemColor (DWT.COLOR_BLACK);
- case DWT.COLOR_INFO_BACKGROUND: return Color.cocoa_new (this, new float [] [0xFF / 255f, 0xFF / 255f, 0xE1 / 255f, 1]);
+ case DWT.COLOR_INFO_BACKGROUND: return Color.cocoa_new (this, [0xFF / 255f, 0xFF / 255f, 0xE1 / 255f, 1]);
case DWT.COLOR_TITLE_FOREGROUND: color = NSColor.windowFrameTextColor(); break;
case DWT.COLOR_TITLE_BACKGROUND: color = NSColor.secondarySelectedControlColor(); break;
case DWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = NSColor.windowFrameColor(); break;
@@ -1452,7 +1481,7 @@
if (color is null) return super.getSystemColor(id);
float[] components = new float[color.numberOfComponents()];
color.getComponents(components);
- return Color.cocoa_new (this, new float[][components[0], components[1], components[2], components[3]]);
+ return Color.cocoa_new (this, [components[0], components[1], components[2], components[3]]);
}
/**
@@ -1550,7 +1579,7 @@
default:
return null;
}
- NSImage nsImage = NSWorkspace.sharedWorkspace().iconForFileType(new NSString(OS.NSFileTypeForHFSTypeCode(code)));
+ NSImage nsImage = NSWorkspace.sharedWorkspace().iconForFileType(OS.NSFileTypeForHFSTypeCode(code));
if (nsImage is null) return null;
return Image.cocoa_new(this, DWT.ICON, nsImage);
}
@@ -1606,10 +1635,10 @@
}
void initApplicationDelegate() {
- auto appProc3 = &applicationDelegateProc;
+ objc.IMP appProc3 = cast(objc.IMP) &applicationDelegateProc;
String className = "SWTApplicationDelegate";
- objc.Class cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+ objc.Class cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSObject, className, 0);
OS.class_addMethod(cls, OS.sel_applicationWillFinishLaunching_1, appProc3, "@:@");
OS.class_addMethod(cls, OS.sel_terminate_1, appProc3, "@:@");
OS.class_addMethod(cls, OS.sel_orderFrontStandardAboutPanel_1, appProc3, "@:@");
@@ -1625,18 +1654,18 @@
}
void initClasses () {
- auto dialogProc3 = &dialogProc;
+ objc.IMP dialogProc3 = cast(objc.IMP) &dialogProc;
- auto proc3 = &windowDelegateProc3;
- auto proc2 = &windowDelegateProc2;
- auto proc4 = &windowDelegateProc4;
- auto proc5 = &windowDelegateProc5;
- auto proc6 = &windowDelegateProc6;
+ objc.IMP proc3 = cast(objc.IMP) &windowDelegateProc3;
+ objc.IMP proc2 = cast(objc.IMP) &windowDelegateProc2;
+ objc.IMP proc4 = cast(objc.IMP) &windowDelegateProc4;
+ objc.IMP proc5 = cast(objc.IMP) &windowDelegateProc5;
+ objc.IMP proc6 = cast(objc.IMP) &windowDelegateProc6;
- auto drawRectProc = OS.drawRect_CALLBACK(proc3);
+ objc.IMP drawRectProc = OS.drawRect_CALLBACK(proc3);
String className = "SWTWindowDelegate";
- objc.Class cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+ objc.Class cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSObject, className, 0);
static if ((void*).sizeof > int.sizeof) // 64bit target
OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "q");
@@ -1655,7 +1684,7 @@
OS.objc_registerClassPair(cls);
className = "SWTPanelDelegate";
- cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSObject, 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_windowWillClose_1, dialogProc3, "@:@");
OS.class_addMethod(cls, OS.sel_changeColor_1, dialogProc3, "@:@");
@@ -1665,7 +1694,7 @@
OS.objc_registerClassPair(cls);
className = "SWTMenu";
- cls = OS.objc_allocateClassPair(OS.class_NSMenu, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSMenu, 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");
@@ -1677,7 +1706,7 @@
OS.objc_registerClassPair(cls);
className = "SWTView";
- cls = OS.objc_allocateClassPair(OS.class_NSView, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSView, 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");
@@ -1694,7 +1723,7 @@
OS.objc_registerClassPair(cls);
className = "SWTScrollView";
- cls = OS.objc_allocateClassPair(OS.class_NSScrollView, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSScrollView, 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");
@@ -1704,7 +1733,7 @@
OS.objc_registerClassPair(cls);
className = "SWTButton";
- cls = OS.objc_allocateClassPair(OS.class_NSButton, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSButton, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
// OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i");
@@ -1714,7 +1743,7 @@
OS.objc_registerClassPair(cls);
className = "SWTTableView";
- cls = OS.objc_allocateClassPair(OS.class_NSTableView, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSTableView, className, 0);
OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:");
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_numberOfRowsInTableView_1, proc3, "@:@");
@@ -1727,7 +1756,7 @@
OS.objc_registerClassPair(cls);
className = "SWTOutlineView";
- cls = OS.objc_allocateClassPair(OS.class_NSOutlineView, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSOutlineView, className, 0);
OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:");
OS.class_addMethod(cls, OS.sel_outlineViewSelectionDidChange_1, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_outlineView_1shouldCollapseItem_1, proc4, "@:@@");
@@ -1742,7 +1771,7 @@
OS.objc_registerClassPair(cls);
className = "SWTTreeItem";
- cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSObject, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
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, "@:");
@@ -1750,7 +1779,7 @@
OS.objc_registerClassPair(cls);
className = "SWTTabView";
- cls = OS.objc_allocateClassPair(OS.class_NSTabView, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSTabView, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
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_tabView_1willSelectTabViewItem_1, proc4, "@:@@");
@@ -1760,7 +1789,7 @@
OS.objc_registerClassPair(cls);
className = "SWTBox";
- cls = OS.objc_allocateClassPair(OS.class_NSBox, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSBox, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
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, "@:");
@@ -1769,7 +1798,7 @@
OS.objc_registerClassPair(cls);
className = "SWTProgressIndicator";
- cls = OS.objc_allocateClassPair(OS.class_NSProgressIndicator, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSProgressIndicator, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
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, "@:");
@@ -1778,20 +1807,20 @@
OS.objc_registerClassPair(cls);
className = "SWTSlider";
- cls = OS.objc_allocateClassPair(OS.class_NSSlider, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSSlider, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
OS.objc_registerClassPair(cls);
className = "SWTPopUpButton";
- cls = OS.objc_allocateClassPair(OS.class_NSPopUpButton, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSPopUpButton, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
OS.objc_registerClassPair(cls);
className = "SWTComboBox";
- cls = OS.objc_allocateClassPair(OS.class_NSComboBox, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSComboBox, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_comboBoxSelectionDidChange_1, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
@@ -1799,14 +1828,14 @@
OS.objc_registerClassPair(cls);
className = "SWTDatePicker";
- cls = OS.objc_allocateClassPair(OS.class_NSDatePicker, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSDatePicker, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
OS.objc_registerClassPair(cls);
className = "SWTImageView";
- cls = OS.objc_allocateClassPair(OS.class_NSImageView, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSImageView, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_drawRect_1, OS.drawRect_CALLBACK(proc3), "@:i");
OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@");
@@ -1816,27 +1845,27 @@
OS.objc_registerClassPair(cls);
className = "SWTStepper";
- cls = OS.objc_allocateClassPair(OS.class_NSStepper, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSStepper, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
OS.objc_registerClassPair(cls);
className = "SWTScroller";
- cls = OS.objc_allocateClassPair(OS.class_NSScroller, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSScroller, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
OS.objc_registerClassPair(cls);
className = "SWTMenuItem";
- cls = OS.objc_allocateClassPair(OS.class_NSMenuItem, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSMenuItem, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
OS.objc_registerClassPair(cls);
className = "SWTTextView";
- cls = OS.objc_allocateClassPair(OS.class_NSTextView, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSTextView, className, 0);
// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
// OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
@@ -1847,12 +1876,12 @@
OS.objc_registerClassPair(cls);
className = "SWTTextField";
- cls = OS.objc_allocateClassPair(OS.class_NSTextField, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSTextField, className, 0);
OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i");
OS.objc_registerClassPair(cls);
className = "SWTWindow";
- cls = OS.objc_allocateClassPair(OS.class_NSWindow, className, 0);
+ cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSWindow, 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");
@@ -1916,14 +1945,16 @@
* @param hDC the platform specific GC handle
* @param data the platform specific GC data
*/
-public void internal_dispose_GC (int context, GCData data) {
+public override void internal_dispose_GC (objc.id context, GCData data) {
if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED);
}
-static bool isValidClass (Class clazz) {
+static bool isValidClass (ClassInfo clazz) {
String name = clazz.name;
int index = name.lastIndexOf ('.');
+ name = name[0 .. index];
+ index = name.lastIndexOf ('.');
return name.substring (0, index + 1).equals (PACKAGE_PREFIX);
}
@@ -2566,9 +2597,9 @@
/* Take an event off the queue */
Event event = eventQueue [0];
if (event is null) break;
- int length = eventQueue.length;
- System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
- eventQueue [length] = null;
+ int length_ = eventQueue.length;
+ System.arraycopy (eventQueue, 1, eventQueue, 0, --length_);
+ eventQueue [length_] = null;
/* Run the event */
Widget widget = event.widget;
@@ -2633,20 +2664,8 @@
}
//TODO - use custom timer instead of timerExec
-Runnable caretTimer = new class Runnable {
- public void run () {
- if (currentCaret !is null) {
- if (currentCaret is null || currentCaret.isDisposed()) return;
- if (currentCaret.blinkCaret ()) {
- int blinkRate = currentCaret.blinkRate;
- if (blinkRate !is 0) timerExec (blinkRate, this);
- } else {
- currentCaret = null;
- }
- }
-
- }
-};
+Runnable caretTimer;
+
void setCurrentCaret (Caret caret) {
// if (caretID !is 0) OS.RemoveEventLoopTimer (caretID);
// caretID = 0;
@@ -2753,8 +2772,8 @@
/* Add the key/value pair */
if (keys is null) {
- keys = new String [] [key];
- values = new Object [] [value];
+ keys = [key];
+ values = [value];
return;
}
for (int i=0; i
*******************************************************************************/
module dwt.widgets.FontDialog;
-import dwt.dwthelper.utils;
-
import dwt.DWT;
import dwt.DWTException;
import dwt.graphics.Font;
@@ -27,6 +28,12 @@
import dwt.internal.cocoa.OS;
import dwt.internal.cocoa.SWTPanelDelegate;
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSInteger;
+import dwt.widgets.Dialog;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+
/**
* Instances of this class allow the user to select a font
* from all available fonts in the system.
@@ -44,250 +51,250 @@
public class FontDialog : Dialog {
FontData fontData;
RGB rgb;
- bool open;
+ bool open_;
int fontID, fontSize;
-
-/**
- * Constructs a new instance of this class given only its parent.
- *
- * @param parent a shell which will be the parent of the new instance
- *
- * @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the parent is null
- *
- * @exception DWTException
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- * - ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- *
- */
-public this (Shell parent) {
- this (parent, DWT.APPLICATION_MODAL);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- *
- * The style value is either one of the style constants defined in
- * class DWT
which is applicable to instances of this
- * class, or must be built by bitwise OR'ing together
- * (that is, using the int
"|" operator) two or more
- * of those DWT
style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- *
- *
- * @param parent a shell which will be the parent of the new instance
- * @param style the style of dialog to construct
- *
- * @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the parent is null
- *
- * @exception DWTException
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- * - ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- *
- */
-public this (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
-void changeFont(int arg0) {
-}
-
-/**
- * Returns a FontData object describing the font that was
- * selected in the dialog, or null if none is available.
- *
- * @return the FontData for the selected font, or null
- * @deprecated use #getFontList ()
- */
-public FontData getFontData () {
- return fontData;
-}
-
-/**
- * Returns a FontData set describing the font that was
- * selected in the dialog, or null if none is available.
- *
- * @return the FontData for the selected font, or null
- * @since 2.1.1
- */
-public FontData [] getFontList () {
- if (fontData is null) return null;
- FontData [] result = new FontData [1];
- result [0] = fontData;
- return result;
-}
-
-/**
- * Returns an RGB describing the color that was selected
- * in the dialog, or null if none is available.
- *
- * @return the RGB value for the selected color, or null
- *
- * @see PaletteData#getRGBs
- *
- * @since 2.1
- */
-public RGB getRGB () {
- return rgb;
-}
-
-//int fontProc (int nextHandler, int theEvent, int userData) {
-// int kind = OS.GetEventKind (theEvent);
-// switch (kind) {
-// case OS.kEventFontPanelClosed:
-// open = false;
-// break;
-// case OS.kEventFontSelection:
-// int [] fontID = new int [1];
-// if (OS.GetEventParameter (theEvent, OS.kEventParamATSUFontID, OS.typeUInt32, null, 4, null, fontID) is OS.noErr) {
-// this.fontID = fontID [0];
-// }
-// int [] fontSize = new int [1];
-// if (OS.GetEventParameter (theEvent, OS.kEventParamATSUFontSize, OS.typeFixed, null, 4, null, fontSize) is OS.noErr) {
-// this.fontSize = fontSize [0];
-// }
-// RGBColor color = new RGBColor ();
-// int [] actualSize = new int [1];
-// if (OS.GetEventParameter (theEvent, OS.kEventParamFontColor, OS.typeRGBColor, null, RGBColor.sizeof, actualSize, color) is OS.noErr) {
-// int red = (color.red >> 8) & 0xFF;
-// int green = (color.green >> 8) & 0xFF;
-// int blue = (color.blue >> 8) & 0xFF;
-// rgb = new RGB (red, green, blue);
-// } else {
-// int [] dict = new int [1];
-// if (OS.GetEventParameter (theEvent, OS.kEventParamDictionary, OS.typeCFDictionaryRef, null, 4, actualSize, dict) is OS.noErr) {
-// int [] attrib = new int [1];
-// if (OS.CFDictionaryGetValueIfPresent (dict [0], OS.kFontPanelAttributesKey (), attrib)) {
-// int [] tags = new int [1];
-// int [] sizes = new int [1];
-// int [] values = new int [1];
-// if (OS.CFDictionaryGetValueIfPresent (attrib [0], OS.kFontPanelAttributeTagsKey (), tags) &&
-// OS.CFDictionaryGetValueIfPresent (attrib [0], OS.kFontPanelAttributeSizesKey (), sizes) &&
-// OS.CFDictionaryGetValueIfPresent (attrib [0], OS.kFontPanelAttributeValuesKey (), values)
-// ) {
-// int count = OS.CFDataGetLength (tags [0]) / 4;
-// int tagPtr = OS.CFDataGetBytePtr (tags[0]);
-// int sizePtr = OS.CFDataGetBytePtr (sizes [0]);
-// int [] tag = new int [1];
-// int [] size = new int [1];
-// int valueOffset = 0;
-// for (int i = 0 ; i < count ; i++) {
-// OS.memmove (tag, tagPtr + (i * 4), 4);
-// OS.memmove (size, sizePtr + (i * 4), 4);
-// if (tag [0] is OS.kATSUColorTag && size[0] is RGBColor.sizeof) {
-// int valuePtr = OS.CFDataGetBytePtr (values [0]);
-// OS.memmove (color, valuePtr + valueOffset, RGBColor.sizeof);
-// int red = (color.red >> 8) & 0xFF;
-// int green = (color.green >> 8) & 0xFF;
-// int blue = (color.blue >> 8) & 0xFF;
-// rgb = new RGB (red, green, blue);
-// break ;
-// }
-// valueOffset = size[0];
-// }
-// }
-// }
-// }
-// }
-// break;
-// }
-// return OS.noErr;
-//}
+
+ /**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the parent is null
+ *
+ * @exception DWTException
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
+ * - ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
+ *
+ */
+ public this (Shell parent) {
+ this (parent, DWT.APPLICATION_MODAL);
+ }
+
+ /**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ *
+ * The style value is either one of the style constants defined in
+ * class DWT
which is applicable to instances of this
+ * class, or must be built by bitwise OR'ing together
+ * (that is, using the int
"|" operator) two or more
+ * of those DWT
style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ *
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of dialog to construct
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the parent is null
+ *
+ * @exception DWTException
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
+ * - ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
+ *
+ */
+ public this (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+ }
+
+ void changeFont(int arg0) {
+ }
+
+ /**
+ * Returns a FontData object describing the font that was
+ * selected in the dialog, or null if none is available.
+ *
+ * @return the FontData for the selected font, or null
+ * @deprecated use #getFontList ()
+ */
+ public FontData getFontData () {
+ return fontData;
+ }
+
+ /**
+ * Returns a FontData set describing the font that was
+ * selected in the dialog, or null if none is available.
+ *
+ * @return the FontData for the selected font, or null
+ * @since 2.1.1
+ */
+ public FontData [] getFontList () {
+ if (fontData is null) return null;
+ FontData [] result = new FontData [1];
+ result [0] = fontData;
+ return result;
+ }
+
+ /**
+ * Returns an RGB describing the color that was selected
+ * in the dialog, or null if none is available.
+ *
+ * @return the RGB value for the selected color, or null
+ *
+ * @see PaletteData#getRGBs
+ *
+ * @since 2.1
+ */
+ public RGB getRGB () {
+ return rgb;
+ }
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a FontData object describing the font that was selected,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception DWTException
- * - ERROR_WIDGET_DISPOSED - if the dialog has been disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog
- *
- */
-public FontData open () {
- Display display = parent !is null ? parent.display : Display.getCurrent ();
+ //int fontProc (int nextHandler, int theEvent, int userData) {
+ // int kind = OS.GetEventKind (theEvent);
+ // switch (kind) {
+ // case OS.kEventFontPanelClosed:
+ // open = false;
+ // break;
+ // case OS.kEventFontSelection:
+ // int [] fontID = new int [1];
+ // if (OS.GetEventParameter (theEvent, OS.kEventParamATSUFontID, OS.typeUInt32, null, 4, null, fontID) is OS.noErr) {
+ // this.fontID = fontID [0];
+ // }
+ // int [] fontSize = new int [1];
+ // if (OS.GetEventParameter (theEvent, OS.kEventParamATSUFontSize, OS.typeFixed, null, 4, null, fontSize) is OS.noErr) {
+ // this.fontSize = fontSize [0];
+ // }
+ // RGBColor color = new RGBColor ();
+ // int [] actualSize = new int [1];
+ // if (OS.GetEventParameter (theEvent, OS.kEventParamFontColor, OS.typeRGBColor, null, RGBColor.sizeof, actualSize, color) is OS.noErr) {
+ // int red = (color.red >> 8) & 0xFF;
+ // int green = (color.green >> 8) & 0xFF;
+ // int blue = (color.blue >> 8) & 0xFF;
+ // rgb = new RGB (red, green, blue);
+ // } else {
+ // int [] dict = new int [1];
+ // if (OS.GetEventParameter (theEvent, OS.kEventParamDictionary, OS.typeCFDictionaryRef, null, 4, actualSize, dict) is OS.noErr) {
+ // int [] attrib = new int [1];
+ // if (OS.CFDictionaryGetValueIfPresent (dict [0], OS.kFontPanelAttributesKey (), attrib)) {
+ // int [] tags = new int [1];
+ // int [] sizes = new int [1];
+ // int [] values = new int [1];
+ // if (OS.CFDictionaryGetValueIfPresent (attrib [0], OS.kFontPanelAttributeTagsKey (), tags) &&
+ // OS.CFDictionaryGetValueIfPresent (attrib [0], OS.kFontPanelAttributeSizesKey (), sizes) &&
+ // OS.CFDictionaryGetValueIfPresent (attrib [0], OS.kFontPanelAttributeValuesKey (), values)
+ // ) {
+ // int count = OS.CFDataGetLength (tags [0]) / 4;
+ // int tagPtr = OS.CFDataGetBytePtr (tags[0]);
+ // int sizePtr = OS.CFDataGetBytePtr (sizes [0]);
+ // int [] tag = new int [1];
+ // int [] size = new int [1];
+ // int valueOffset = 0;
+ // for (int i = 0 ; i < count ; i++) {
+ // OS.memmove (tag, tagPtr + (i * 4), 4);
+ // OS.memmove (size, sizePtr + (i * 4), 4);
+ // if (tag [0] is OS.kATSUColorTag && size[0] is RGBColor.sizeof) {
+ // int valuePtr = OS.CFDataGetBytePtr (values [0]);
+ // OS.memmove (color, valuePtr + valueOffset, RGBColor.sizeof);
+ // int red = (color.red >> 8) & 0xFF;
+ // int green = (color.green >> 8) & 0xFF;
+ // int blue = (color.blue >> 8) & 0xFF;
+ // rgb = new RGB (red, green, blue);
+ // break ;
+ // }
+ // valueOffset = size[0];
+ // }
+ // }
+ // }
+ // }
+ // }
+ // break;
+ // }
+ // return OS.noErr;
+ //}
- NSFontPanel panel = NSFontPanel.sharedFontPanel();
- panel.setTitle(NSString.stringWith(title !is null ? title : ""));
- if (fontData !is null) {
- Font font = new Font(display, fontData);
- NSFontManager.sharedFontManager().setSelectedFont(font.handle, false);
- font.dispose();
- }
- SWTPanelDelegate delegate = cast(SWTPanelDelegate)new SWTPanelDelegate().alloc().init();
- int jniRef = OS.NewGlobalRef(this);
- if (jniRef is 0) DWT.error(DWT.ERROR_NO_HANDLES);
- delegate.setTag(jniRef);
- panel.setDelegate(delegate);
- fontData = null;
- panel.orderFront(null);
- NSApplication.sharedApplication().runModalForWindow_(panel);
- panel.setDelegate(null);
- delegate.release();
- OS.DeleteGlobalRef(jniRef);
- NSFont font = NSFontManager.sharedFontManager().selectedFont();
- if (font !is null) {
- //TODO - this does work
- fontData = Font.cocoa_new(display, font).getFontData()[0];
+ /**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a FontData object describing the font that was selected,
+ * or null if the dialog was cancelled or an error occurred
+ *
+ * @exception DWTException
+ * - ERROR_WIDGET_DISPOSED - if the dialog has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog
+ *
+ */
+ public FontData open () {
+ Display display = parent !is null ? parent.display : Display.getCurrent ();
+
+ NSFontPanel panel = NSFontPanel.sharedFontPanel();
+ panel.setTitle(NSString.stringWith(title !is null ? title : ""));
+ if (fontData !is null) {
+ Font font = new Font(display, fontData);
+ NSFontManager.sharedFontManager().setSelectedFont(font.handle, false);
+ font.dispose();
+ }
+ SWTPanelDelegate delegate_ = cast(SWTPanelDelegate)(new SWTPanelDelegate()).alloc().init();
+ NSInteger jniRef = OS.NewGlobalRef(this);
+ if (jniRef is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+ delegate_.setTag(jniRef);
+ panel.setDelegate(delegate_);
+ fontData = null;
+ panel.orderFront(null);
+ NSApplication.sharedApplication().runModalForWindow_(panel);
+ panel.setDelegate(null);
+ delegate_.release();
+ OS.DeleteGlobalRef(jniRef);
+ NSFont font = NSFontManager.sharedFontManager().selectedFont();
+ if (font !is null) {
+ //TODO - this does work
+ fontData = Font.cocoa_new(display, font).getFontData()[0];
+ }
+ return fontData;
}
- return fontData;
-}
-
-/**
- * Sets a FontData object describing the font to be
- * selected by default in the dialog, or null to let
- * the platform choose one.
- *
- * @param fontData the FontData to use initially, or null
- * @deprecated use #setFontList (FontData [])
- */
-public void setFontData (FontData fontData) {
- this.fontData = fontData;
-}
-
-/**
- * Sets the set of FontData objects describing the font to
- * be selected by default in the dialog, or null to let
- * the platform choose one.
- *
- * @param fontData the set of FontData objects to use initially, or null
- * to let the platform select a default when open() is called
- *
- * @see Font#getFontData
- *
- * @since 2.1.1
- */
-public void setFontList (FontData [] fontData) {
- if (fontData !is null && fontData.length > 0) {
- this.fontData = fontData [0];
- } else {
- this.fontData = null;
+
+ /**
+ * Sets a FontData object describing the font to be
+ * selected by default in the dialog, or null to let
+ * the platform choose one.
+ *
+ * @param fontData the FontData to use initially, or null
+ * @deprecated use #setFontList (FontData [])
+ */
+ public void setFontData (FontData fontData) {
+ this.fontData = fontData;
}
-}
-
-/**
- * Sets the RGB describing the color to be selected by default
- * in the dialog, or null to let the platform choose one.
- *
- * @param rgb the RGB value to use initially, or null to let
- * the platform select a default when open() is called
- *
- * @see PaletteData#getRGBs
- *
- * @since 2.1
- */
-public void setRGB (RGB rgb) {
- this.rgb = rgb;
-}
-
-void windowWillClose(int sender) {
- NSApplication.sharedApplication().stop(null);
-}
-
-}
+
+ /**
+ * Sets the set of FontData objects describing the font to
+ * be selected by default in the dialog, or null to let
+ * the platform choose one.
+ *
+ * @param fontData the set of FontData objects to use initially, or null
+ * to let the platform select a default when open() is called
+ *
+ * @see Font#getFontData
+ *
+ * @since 2.1.1
+ */
+ public void setFontList (FontData [] fontData) {
+ if (fontData !is null && fontData.length > 0) {
+ this.fontData = fontData [0];
+ } else {
+ this.fontData = null;
+ }
+ }
+
+ /**
+ * Sets the RGB describing the color to be selected by default
+ * in the dialog, or null to let the platform choose one.
+ *
+ * @param rgb the RGB value to use initially, or null to let
+ * the platform select a default when open() is called
+ *
+ * @see PaletteData#getRGBs
+ *
+ * @since 2.1
+ */
+ public void setRGB (RGB rgb) {
+ this.rgb = rgb;
+ }
+
+ void windowWillClose(int sender) {
+ NSApplication.sharedApplication().stop(null);
+ }
+
+ }
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Layout.d
--- a/dwt/widgets/Layout.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Layout.d Fri Oct 10 12:29:48 2008 +0200
@@ -62,7 +62,7 @@
* @see Control#pack(bool)
* @see "computeTrim, getClientArea for controls that implement them"
*/
-protected abstract Point computeSize (Composite composite, int wHint, int hHint, bool flushCache);
+public abstract Point computeSize (Composite composite, int wHint, int hHint, bool flushCache);
/**
* Instruct the layout to flush any cached values
@@ -74,7 +74,7 @@
*
* @since 3.1
*/
-protected bool flushCache (Control control) {
+public bool flushCache (Control control) {
return false;
}
@@ -106,5 +106,5 @@
* @param composite a composite widget using this layout
* @param flushCache true
means flush cached layout values
*/
-protected abstract void layout (Composite composite, bool flushCache);
+public abstract void layout (Composite composite, bool flushCache);
}
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Menu.d
--- a/dwt/widgets/Menu.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Menu.d Fri Oct 10 12:29:48 2008 +0200
@@ -220,7 +220,7 @@
} else {
location = window.mouseLocationOutsideOfEventStream();
}
- NSEvent nsEvent = NSEvent.otherEventWithType(OS.NSApplicationDefined, location, 0, 0.0, window.windowNumber(), window.graphicsContext(), cast(short)0, 0, 0);
+ NSEvent nsEvent = NSEvent.otherEventWithType(NSApplicationDefined, location, 0, 0.0, window.windowNumber(), window.graphicsContext(), cast(short)0, 0, 0);
NSMenu.static_popUpContextMenu_withEvent_forView_ (nsMenu, nsEvent, shell.view);
} else {
nsMenu.cancelTracking ();
@@ -464,12 +464,12 @@
String getNameText () {
String result = "";
MenuItem [] items = getItems ();
- int length = items.length;
- if (length > 0) {
- for (int i=0; i 0) {
+ for (int i=0; i
*******************************************************************************/
@@ -571,7 +571,7 @@
} else {
str = NSString.stringWith (Integer.toString(key)).lowercaseString();
}
- nsItem.setKeyEquivalent (string);
+ nsItem.setKeyEquivalent (str);
int mask = 0;
if ((accelerator & DWT.SHIFT) !is 0) mask |= OS.NSShiftKeyMask;
if ((accelerator & DWT.CONTROL) !is 0) mask |= OS.NSControlKeyMask;
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Monitor.d
--- a/dwt/widgets/Monitor.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Monitor.d Fri Oct 10 12:29:48 2008 +0200
@@ -51,6 +51,8 @@
dwt.widgets.Monitor.Monitor monitor = cast(dwt.widgets.Monitor.Monitor) object;
return handle is monitor.handle;
}
+
+alias opEquals equals;
/**
* Returns a rectangle describing the receiver's size and location
@@ -87,4 +89,6 @@
return cast(hash_t)/*64*/handle;
}
+alias toHash hashCode;
+
}
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/RunnableLock.d
--- a/dwt/widgets/RunnableLock.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/RunnableLock.d Fri Oct 10 12:29:48 2008 +0200
@@ -9,16 +9,19 @@
* IBM Corporation - initial API and implementation
*
* Port to the D programming language:
+ * Frank Benoit
* Jacob Carlborg
*******************************************************************************/
module dwt.widgets.RunnableLock;
+import tango.core.Exception;
+import tango.core.sync.Condition;
+import tango.core.sync.Mutex;
import tango.core.Thread;
import dwt.dwthelper.Runnable;
import dwt.dwthelper.utils;
-
/**
* Instances of this class are used to ensure that an
* application cannot interfere with the locking mechanism
@@ -26,13 +29,16 @@
* between widgets and background threads.
*/
-class RunnableLock {
+class RunnableLock : Mutex {
Runnable runnable;
Thread thread;
Throwable throwable;
+ Condition cond;
+
this (Runnable runnable) {
this.runnable = runnable;
+ this.cond = new Condition(this);
}
bool done () {
@@ -43,5 +49,12 @@
if (runnable !is null) runnable.run ();
runnable = null;
}
+
+void notifyAll(){
+ cond.notifyAll();
+}
+void wait(){
+ cond.wait();
+}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/ScrollBar.d
--- a/dwt/widgets/ScrollBar.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/ScrollBar.d Fri Oct 10 12:29:48 2008 +0200
@@ -100,7 +100,7 @@
int increment = 1;
int pageIncrement = 10;
id target;
- int actionSelector;;
+ String actionSelector;;
this () {
/* Do nothing */
@@ -422,23 +422,23 @@
Event event = new Event();
NSScrollerPart hitPart = (cast(NSScroller)view).hitPart();
switch (hitPart) {
- case OS.NSScrollerDecrementLine:
+ case NSScrollerDecrementLine:
value -= increment;
event.detail = DWT.ARROW_UP;
break;
- case OS.NSScrollerDecrementPage:
+ case NSScrollerDecrementPage:
value -= pageIncrement;
event.detail = DWT.PAGE_UP;
break;
- case OS.NSScrollerIncrementLine:
+ case NSScrollerIncrementLine:
value += increment;
event.detail = DWT.PAGE_DOWN;
break;
- case OS.NSScrollerIncrementPage:
+ case NSScrollerIncrementPage:
value += pageIncrement;
event.detail = DWT.ARROW_DOWN;
break;
- case OS.NSScrollerKnob:
+ case NSScrollerKnob:
event.detail = DWT.DRAG;
break;
}
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Scrollable.d
--- a/dwt/widgets/Scrollable.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Scrollable.d Fri Oct 10 12:29:48 2008 +0200
@@ -120,7 +120,7 @@
NSSize size = NSSize();
size.width = width;
size.height = height;
- int border = hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder;
+ NSBorderType border = hasBorder() ? NSBezelBorder : NSNoBorder;
size = NSScrollView.frameSizeForContentSize(size, (style & DWT.H_SCROLL) !is 0, (style & DWT.V_SCROLL) !is 0, border);
width = cast(int)size.width;
height = cast(int)size.height;
@@ -138,7 +138,7 @@
bar.style = style;
bar.display = display;
NSScroller scroller;
- int actionSelector;
+ String actionSelector;
if ((style & DWT.H_SCROLL) !is 0) {
scroller = scrollView.horizontalScroller();
actionSelector = OS.sel_sendHorizontalSelection;
@@ -147,7 +147,7 @@
actionSelector = OS.sel_sendVerticalSelection;
}
bar.view = scroller;
- bar.createJNIRef();
+ //bar.createJNIRef();
scroller.setTag(bar.jniRef);
if ((state & CANVAS) is 0) {
bar.target = scroller.target();
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Shell.d
--- a/dwt/widgets/Shell.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Shell.d Fri Oct 10 12:29:48 2008 +0200
@@ -276,7 +276,7 @@
* @see DWT#SYSTEM_MODAL
*/
public this (Display display, int style) {
- this (display, null, style, 0, false);
+ this (display, null, style, null, false);
}
this (Display display, Shell parent, int style, objc.id handle, bool embedded) {
@@ -378,7 +378,7 @@
* @see DWT#SYSTEM_MODAL
*/
public this (Shell parent, int style) {
- this (parent !is null ? parent.display : null, parent, style, 0, false);
+ this (parent !is null ? parent.display : null, parent, style, null, false);
}
public static Shell internal_new (Display display, objc.id handle) {
@@ -491,22 +491,22 @@
Rectangle clientArea = monitor.getClientArea ();
rect.width = clientArea.width * 5 / 8;
rect.height = clientArea.height * 5 / 8;
- int styleMask = OS.NSBorderlessWindowMask;
+ NSUInteger styleMask = NSBorderlessWindowMask;
if ((style & DWT.NO_TRIM) is 0) {
styleMask = OS.NSTitledWindowMask;
- if ((style & DWT.CLOSE) !is 0) styleMask |= OS.NSClosableWindowMask;
- if ((style & DWT.MIN) !is 0) styleMask |= OS.NSMiniaturizableWindowMask;
- if ((style & DWT.MAX) !is 0) styleMask |= OS.NSResizableWindowMask;
- if ((style & DWT.RESIZE) !is 0) styleMask |= OS.NSResizableWindowMask;
+ if ((style & DWT.CLOSE) !is 0) styleMask |= NSClosableWindowMask;
+ if ((style & DWT.MIN) !is 0) styleMask |= NSMiniaturizableWindowMask;
+ if ((style & DWT.MAX) !is 0) styleMask |= NSResizableWindowMask;
+ if ((style & DWT.RESIZE) !is 0) styleMask |= NSResizableWindowMask;
}
- window = window.initWithContentRect_styleMask_backing_defer_(rect, styleMask, OS.NSBackingStoreBuffered, false);
+ window = window.initWithContentRect_styleMask_backing_defer_(rect, styleMask, NSBackingStoreBuffered, false);
display.cascade = window.cascadeTopLeftFromPoint(display.cascade);
if ((style & DWT.ON_TOP) !is 0) {
window.setLevel(OS.NSFloatingWindowLevel);
}
}
- createHandle (null);
+ (cast(Composite)this).createHandle (null);
window.setContentView (topView());
windowDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init();
@@ -555,19 +555,19 @@
Event event = new Event ();
event.keyCode = DWT.CAPS_LOCK;
// setInputState (event, DWT.KeyDown, chord, modifiers);
- target.sendKeyEvent (DWT.KeyDown, event);
+ (cast(Widget)target).sendKeyEvent (DWT.KeyDown, event);
}
}
Event event = new Event ();
// setInputState (event, type, chord, modifiers);
if (event.keyCode is 0 && event.character is 0) return;
- bool result = sendKeyEvent (type, event);
+ bool result = (cast(Widget)this).sendKeyEvent (type, event);
if (type is DWT.KeyDown && (modifiers & OS.NSAlphaShiftKeyMask) !is 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) is 0) {
if (target !is null) {
event = new Event ();
event.keyCode = DWT.CAPS_LOCK;
// setInputState (event, DWT.KeyUp, chord, modifiers);
- target.sendKeyEvent (DWT.KeyUp, event);
+ (cast(Widget)target).sendKeyEvent (DWT.KeyUp, event);
}
}
display.lastModifiers = modifiers;
@@ -621,7 +621,7 @@
NSSize size = NSSize();
size.width = width;
size.height = height;
- size = NSScrollView.contentSizeForFrameSize(size, (style & DWT.H_SCROLL) !is 0, (style & DWT.V_SCROLL) !is 0, OS.NSNoBorder);
+ size = NSScrollView.contentSizeForFrameSize(size, (style & DWT.H_SCROLL) !is 0, (style & DWT.V_SCROLL) !is 0, NSNoBorder);
width = cast(int)size.width;
height = cast(int)size.height;
}
@@ -1231,7 +1231,7 @@
public void setText (String str) {
checkWidget();
- if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+ if (str is null) error (DWT.ERROR_NULL_ARGUMENT);
super.setText (str);
NSString nsStr = NSString.stringWith(str);
window.setTitle(nsStr);
@@ -1263,7 +1263,7 @@
resized = true;
sendEvent (DWT.Resize);
if (isDisposed ()) return;
- if (layout !is null) {
+ if (layout_ !is null) {
markLayout (false, false);
updateLayout (false);
}
@@ -1301,7 +1301,7 @@
Shell activeShell = display.getActiveShell ();
Shell current = this;
while (current !is null) {
- if (current.equals (activeShell)) {
+ if (current.opEquals (activeShell)) {
isActive = true;
break;
}
@@ -1338,7 +1338,7 @@
resized = true;
sendEvent (DWT.Resize);
if (isDisposed ()) return;
- if (layout !is null) {
+ if (layout_ !is null) {
markLayout (false, false);
updateLayout (false);
}
@@ -1389,7 +1389,7 @@
if (!eventTarget.sendKeyEvent(nsEvent, type is OS.NSKeyDown ? DWT.KeyDown : DWT.KeyUp)) return;
}
}
- super.windowSendEvent(id, event);
+ super.windowSendEvent(ID, event);
}
}
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Synchronizer.d
--- a/dwt/widgets/Synchronizer.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Synchronizer.d Fri Oct 10 12:29:48 2008 +0200
@@ -48,7 +48,7 @@
Display display;
int messageCount;
RunnableLock [] messages;
- Object messageLock = new Object ();
+ Object messageLock;
Thread syncThread;
static const int GROW_SIZE = 4;
static const int MESSAGE_LIMIT = 64;
@@ -63,6 +63,7 @@
*/
public this (Display display) {
this.display = display;
+ messageLock = new Object ();
}
void addLast (RunnableLock lock) {
@@ -91,7 +92,7 @@
*
* @see #syncExec
*/
-protected void asyncExec (Runnable runnable) {
+public void asyncExec (Runnable runnable) {
if (runnable is null) {
//TEMPORARY CODE
if (!IS_CARBON) {
@@ -168,7 +169,7 @@
*
* @see #asyncExec
*/
-protected void syncExec (Runnable runnable) {
+public void syncExec (Runnable runnable) {
RunnableLock lock = null;
synchronized (Device.classinfo) {
if (display is null || display.isDisposed ()) DWT.error (DWT.ERROR_DEVICE_DISPOSED);
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/ToolTip.d
--- a/dwt/widgets/ToolTip.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/ToolTip.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,11 +7,12 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ *
+ * Port to the D programming language:
+ * Jacob Carlborg
*******************************************************************************/
module dwt.widgets.ToolTip;
-import dwt.dwthelper.utils;
-
import dwt.DWT;
import dwt.DWTException;
@@ -28,6 +29,16 @@
import dwt.graphics.TextLayout;
import dwt.graphics.TextStyle;
+import dwt.dwthelper.Runnable;
+import dwt.dwthelper.utils;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Listener;
+import dwt.widgets.Shell;
+import dwt.widgets.TrayItem;
+import dwt.widgets.TypedListener;
+import dwt.widgets.Widget;
+
/**
* Instances of this class represent popup windows that are used
* to inform or warn the user.
@@ -66,572 +77,572 @@
static final int TIP_HEIGHT = 20;
static final int IMAGE_SIZE = 16;
static final int DELAY = 10000;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- *
- * The style value is either one of the style constants defined in
- * class DWT
which is applicable to instances of this
- * class, or must be built by bitwise OR'ing together
- * (that is, using the int
"|" operator) two or more
- * of those DWT
style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- *
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the parent is null
- *
- * @exception DWTException
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- * - ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- *
- *
- * @see DWT#ICON_ERROR
- * @see DWT#ICON_INFORMATION
- * @see DWT#ICON_WARNING
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public this (Shell parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- this.autohide = true;
- x = y = -1;
- Display display = getDisplay ();
- tip = new Shell (parent, DWT.ON_TOP | DWT.NO_TRIM);
- Color background = display.getSystemColor (DWT.COLOR_INFO_BACKGROUND);
- tip.setBackground (background);
- listener = new class Listener {
- public void handleEvent (Event event) {
- switch (event.type) {
- case DWT.Dispose: onDispose (event); break;
- case DWT.Paint: onPaint (event); break;
- case DWT.MouseDown: onMouseDown (event); break;
+
+ /**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ *
+ * The style value is either one of the style constants defined in
+ * class DWT
which is applicable to instances of this
+ * class, or must be built by bitwise OR'ing together
+ * (that is, using the int
"|" operator) two or more
+ * of those DWT
style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ *
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the parent is null
+ *
+ * @exception DWTException
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
+ * - ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
+ *
+ *
+ * @see DWT#ICON_ERROR
+ * @see DWT#ICON_INFORMATION
+ * @see DWT#ICON_WARNING
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+ public this (Shell parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ this.autohide = true;
+ x = y = -1;
+ Display display = getDisplay ();
+ tip = new Shell (parent, DWT.ON_TOP | DWT.NO_TRIM);
+ Color background = display.getSystemColor (DWT.COLOR_INFO_BACKGROUND);
+ tip.setBackground (background);
+ listener = new class Listener {
+ public void handleEvent (Event event) {
+ switch (event.type) {
+ case DWT.Dispose: onDispose (event); break;
+ case DWT.Paint: onPaint (event); break;
+ case DWT.MouseDown: onMouseDown (event); break;
+ }
}
- }
- };
- addListener (DWT.Dispose, listener);
- tip.addListener (DWT.Paint, listener);
- tip.addListener (DWT.MouseDown, listener);
-}
-
-static int checkStyle (int style) {
- int mask = DWT.ICON_ERROR | DWT.ICON_INFORMATION | DWT.ICON_WARNING;
- if ((style & mask) is 0) return style;
- return checkBits (style, DWT.ICON_INFORMATION, DWT.ICON_WARNING, DWT.ICON_ERROR, 0, 0, 0);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver is selected by the user, by sending
- * it one of the messages defined in the SelectionListener
- * interface.
- *
- * widgetSelected
is called when the receiver is selected.
- * widgetDefaultSelected
is not called.
- *
- *
- * @param listener the listener which should be notified when the receiver is selected by the user
- *
- * @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 SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- checkWidget ();
- if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (DWT.Selection,typedListener);
- addListener (DWT.DefaultSelection,typedListener);
-}
-
-void configure () {
- Display display = parent.getDisplay ();
- int x = this.x;
- int y = this.y;
- if (x is -1 || y is -1) {
- Point point = display.getCursorLocation ();
- x = point.x;
- y = point.y;
+ };
+ addListener (DWT.Dispose, listener);
+ tip.addListener (DWT.Paint, listener);
+ tip.addListener (DWT.MouseDown, listener);
+ }
+
+ static int checkStyle (int style) {
+ int mask = DWT.ICON_ERROR | DWT.ICON_INFORMATION | DWT.ICON_WARNING;
+ if ((style & mask) is 0) return style;
+ return checkBits (style, DWT.ICON_INFORMATION, DWT.ICON_WARNING, DWT.ICON_ERROR, 0, 0, 0);
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver is selected by the user, by sending
+ * it one of the messages defined in the SelectionListener
+ * interface.
+ *
+ * widgetSelected
is called when the receiver is selected.
+ * widgetDefaultSelected
is not called.
+ *
+ *
+ * @param listener the listener which should be notified when the receiver is selected by the user
+ *
+ * @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 SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+ public void addSelectionListener (SelectionListener listener) {
+ checkWidget ();
+ if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (DWT.Selection,typedListener);
+ addListener (DWT.DefaultSelection,typedListener);
}
- Monitor monitor = parent.getMonitor ();
- Rectangle dest = monitor.getBounds ();
- Point size = getSize (dest.width / 4);
- int w = size.x;
- int h = size.y;
- int t = (style & DWT.BALLOON) !is 0 ? TIP_HEIGHT : 0;
- int i = (style & DWT.BALLOON) !is 0 ? 16 : 0;
- tip.setSize (w, h + t);
- int [] polyline;
- spikeAbove = dest.height >= y + size.y + t;
- if (dest.width >= x + size.x) {
- if (dest.height >= y + size.y + t) {
- polyline = new int [] [
- 0, 5+t, 1, 5+t, 1, 3+t, 3, 1+t, 5, 1+t, 5, t,
- 16, t, 16, 0, 35, t,
- w-5, t, w-5, 1+t, w-3, 1+t, w-1, 3+t, w-1, 5+t, w, 5+t,
- w, h-5+t, w-1, h-5+t, w-1, h-3+t, w-2, h-3+t, w-2, h-2+t, w-3, h-2+t, w-3, h-1+t, w-5, h-1+t, w-5, h+t,
- 5, h+t, 5, h-1+t, 3, h-1+t, 3, h-2+t, 2, h-2+t, 2, h-3+t, 1, h-3+t, 1, h-5+t, 0, h-5+t,
- 0, 5+t];
- borderPolygon = new int[] [
- 0, 5+t, 1, 4+t, 1, 3+t, 3, 1+t, 4, 1+t, 5, t,
- 16, t, 16, 1, 35, t,
- w-6, 0+t, w-5, 1+t, w-4, 1+t, w-2, 3+t, w-2, 4+t, w-1, 5+t,
- w-1, h-6+t, w-2, h-5+t, w-2, h-4+t, w-4, h-2+t, w-5, h-2+t, w-6, h-1+t,
- 5, h-1+t, 4, h-2+t, 3, h-2+t, 1, h-4+t, 1, h-5+t, 0, h-6+t,
- 0, 5+t];
- tip.setLocation (Math.max (0, x - i), y);
- } else {
- polyline = new int [] [
- 0, 5, 1, 5, 1, 3, 3, 1, 5, 1, 5, 0,
- w-5, 0, w-5, 1, w-3, 1, w-1, 3, w-1, 5, w, 5,
- w, h-5, w-1, h-5, w-1, h-3, w-2, h-3, w-2, h-2, w-3, h-2, w-3, h-1, w-5, h-1, w-5, h,
- 35, h, 16, h+t, 16, h,
- 5, h, 5, h-1, 3, h-1, 3, h-2, 2, h-2, 2, h-3, 1, h-3, 1, h-5, 0, h-5,
- 0, 5];
- borderPolygon = new int[] [
- 0, 5, 1, 4, 1, 3, 3, 1, 4, 1, 5, 0,
- w-6, 0, w-5, 1, w-4, 1, w-2, 3, w-2, 4, w-1, 5,
- w-1, h-6, w-2, h-5, w-2, h-4, w-4, h-2, w-5, h-2, w-6, h-1,
- 36, h-1, 16, h+t-1, 16, h-1,
- 5, h-1, 4, h-2, 3, h-2, 1, h-4, 1, h-5, 0, h-6,
- 0, 5];
- tip.setLocation (Math.max (0, x - i), y - size.y - t);
+
+ void configure () {
+ Display display = parent.getDisplay ();
+ int x = this.x;
+ int y = this.y;
+ if (x is -1 || y is -1) {
+ Point point = display.getCursorLocation ();
+ x = point.x;
+ y = point.y;
}
- } else {
- if (dest.height >= y + size.y + t) {
- polyline = new int [] [
- 0, 5+t, 1, 5+t, 1, 3+t, 3, 1+t, 5, 1+t, 5, t,
- w-35, t, w-16, 0, w-16, t,
- w-5, t, w-5, 1+t, w-3, 1+t, w-1, 3+t, w-1, 5+t, w, 5+t,
- w, h-5+t, w-1, h-5+t, w-1, h-3+t, w-2, h-3+t, w-2, h-2+t, w-3, h-2+t, w-3, h-1+t, w-5, h-1+t, w-5, h+t,
- 5, h+t, 5, h-1+t, 3, h-1+t, 3, h-2+t, 2, h-2+t, 2, h-3+t, 1, h-3+t, 1, h-5+t, 0, h-5+t,
- 0, 5+t];
- borderPolygon = new int[] [
- 0, 5+t, 1, 4+t, 1, 3+t, 3, 1+t, 4, 1+t, 5, t,
- w-35, t, w-17, 2, w-17, t,
- w-6, t, w-5, 1+t, w-4, 1+t, w-2, 3+t, w-2, 4+t, w-1, 5+t,
- w-1, h-6+t, w-2, h-5+t, w-2, h-4+t, w-4, h-2+t, w-5, h-2+t, w-6, h-1+t,
- 5, h-1+t, 4, h-2+t, 3, h-2+t, 1, h-4+t, 1, h-5+t, 0, h-6+t,
- 0, 5+t];
- tip.setLocation (Math.min (dest.width - size.x, x - size.x + i), y);
+ dwt.widgets.Monitor.Monitor monitor = parent.getMonitor ();
+ Rectangle dest = monitor.getBounds ();
+ Point size = getSize (dest.width / 4);
+ int w = size.x;
+ int h = size.y;
+ int t = (style & DWT.BALLOON) !is 0 ? TIP_HEIGHT : 0;
+ int i = (style & DWT.BALLOON) !is 0 ? 16 : 0;
+ tip.setSize (w, h + t);
+ int [] polyline;
+ spikeAbove = dest.height >= y + size.y + t;
+ if (dest.width >= x + size.x) {
+ if (dest.height >= y + size.y + t) {
+ polyline = [
+ 0, 5+t, 1, 5+t, 1, 3+t, 3, 1+t, 5, 1+t, 5, t,
+ 16, t, 16, 0, 35, t,
+ w-5, t, w-5, 1+t, w-3, 1+t, w-1, 3+t, w-1, 5+t, w, 5+t,
+ w, h-5+t, w-1, h-5+t, w-1, h-3+t, w-2, h-3+t, w-2, h-2+t, w-3, h-2+t, w-3, h-1+t, w-5, h-1+t, w-5, h+t,
+ 5, h+t, 5, h-1+t, 3, h-1+t, 3, h-2+t, 2, h-2+t, 2, h-3+t, 1, h-3+t, 1, h-5+t, 0, h-5+t,
+ 0, 5+t];
+ borderPolygon = [
+ 0, 5+t, 1, 4+t, 1, 3+t, 3, 1+t, 4, 1+t, 5, t,
+ 16, t, 16, 1, 35, t,
+ w-6, 0+t, w-5, 1+t, w-4, 1+t, w-2, 3+t, w-2, 4+t, w-1, 5+t,
+ w-1, h-6+t, w-2, h-5+t, w-2, h-4+t, w-4, h-2+t, w-5, h-2+t, w-6, h-1+t,
+ 5, h-1+t, 4, h-2+t, 3, h-2+t, 1, h-4+t, 1, h-5+t, 0, h-6+t,
+ 0, 5+t];
+ tip.setLocation (Math.max (0, x - i), y);
+ } else {
+ polyline = [
+ 0, 5, 1, 5, 1, 3, 3, 1, 5, 1, 5, 0,
+ w-5, 0, w-5, 1, w-3, 1, w-1, 3, w-1, 5, w, 5,
+ w, h-5, w-1, h-5, w-1, h-3, w-2, h-3, w-2, h-2, w-3, h-2, w-3, h-1, w-5, h-1, w-5, h,
+ 35, h, 16, h+t, 16, h,
+ 5, h, 5, h-1, 3, h-1, 3, h-2, 2, h-2, 2, h-3, 1, h-3, 1, h-5, 0, h-5,
+ 0, 5];
+ borderPolygon = [
+ 0, 5, 1, 4, 1, 3, 3, 1, 4, 1, 5, 0,
+ w-6, 0, w-5, 1, w-4, 1, w-2, 3, w-2, 4, w-1, 5,
+ w-1, h-6, w-2, h-5, w-2, h-4, w-4, h-2, w-5, h-2, w-6, h-1,
+ 36, h-1, 16, h+t-1, 16, h-1,
+ 5, h-1, 4, h-2, 3, h-2, 1, h-4, 1, h-5, 0, h-6,
+ 0, 5];
+ tip.setLocation (Math.max (0, x - i), y - size.y - t);
+ }
} else {
- polyline = new int [] [
- 0, 5, 1, 5, 1, 3, 3, 1, 5, 1, 5, 0,
- w-5, 0, w-5, 1, w-3, 1, w-1, 3, w-1, 5, w, 5,
- w, h-5, w-1, h-5, w-1, h-3, w-2, h-3, w-2, h-2, w-3, h-2, w-3, h-1, w-5, h-1, w-5, h,
- w-16, h, w-16, h+t, w-35, h,
- 5, h, 5, h-1, 3, h-1, 3, h-2, 2, h-2, 2, h-3, 1, h-3, 1, h-5, 0, h-5,
- 0, 5];
- borderPolygon = new int[] [
- 0, 5, 1, 4, 1, 3, 3, 1, 4, 1, 5, 0,
- w-6, 0, w-5, 1, w-4, 1, w-2, 3, w-2, 4, w-1, 5,
- w-1, h-6, w-2, h-5, w-2, h-4, w-4, h-2, w-5, h-2, w-6, h-1,
- w-17, h-1, w-17, h+t-2, w-36, h-1,
- 5, h-1, 4, h-2, 3, h-2, 1, h-4, 1, h-5, 0, h-6,
- 0, 5];
- tip.setLocation (Math.min (dest.width - size.x, x - size.x + i), y - size.y - t);
+ if (dest.height >= y + size.y + t) {
+ polyline = [
+ 0, 5+t, 1, 5+t, 1, 3+t, 3, 1+t, 5, 1+t, 5, t,
+ w-35, t, w-16, 0, w-16, t,
+ w-5, t, w-5, 1+t, w-3, 1+t, w-1, 3+t, w-1, 5+t, w, 5+t,
+ w, h-5+t, w-1, h-5+t, w-1, h-3+t, w-2, h-3+t, w-2, h-2+t, w-3, h-2+t, w-3, h-1+t, w-5, h-1+t, w-5, h+t,
+ 5, h+t, 5, h-1+t, 3, h-1+t, 3, h-2+t, 2, h-2+t, 2, h-3+t, 1, h-3+t, 1, h-5+t, 0, h-5+t,
+ 0, 5+t];
+ borderPolygon = [
+ 0, 5+t, 1, 4+t, 1, 3+t, 3, 1+t, 4, 1+t, 5, t,
+ w-35, t, w-17, 2, w-17, t,
+ w-6, t, w-5, 1+t, w-4, 1+t, w-2, 3+t, w-2, 4+t, w-1, 5+t,
+ w-1, h-6+t, w-2, h-5+t, w-2, h-4+t, w-4, h-2+t, w-5, h-2+t, w-6, h-1+t,
+ 5, h-1+t, 4, h-2+t, 3, h-2+t, 1, h-4+t, 1, h-5+t, 0, h-6+t,
+ 0, 5+t];
+ tip.setLocation (Math.min (dest.width - size.x, x - size.x + i), y);
+ } else {
+ polyline = [
+ 0, 5, 1, 5, 1, 3, 3, 1, 5, 1, 5, 0,
+ w-5, 0, w-5, 1, w-3, 1, w-1, 3, w-1, 5, w, 5,
+ w, h-5, w-1, h-5, w-1, h-3, w-2, h-3, w-2, h-2, w-3, h-2, w-3, h-1, w-5, h-1, w-5, h,
+ w-16, h, w-16, h+t, w-35, h,
+ 5, h, 5, h-1, 3, h-1, 3, h-2, 2, h-2, 2, h-3, 1, h-3, 1, h-5, 0, h-5,
+ 0, 5];
+ borderPolygon = [
+ 0, 5, 1, 4, 1, 3, 3, 1, 4, 1, 5, 0,
+ w-6, 0, w-5, 1, w-4, 1, w-2, 3, w-2, 4, w-1, 5,
+ w-1, h-6, w-2, h-5, w-2, h-4, w-4, h-2, w-5, h-2, w-6, h-1,
+ w-17, h-1, w-17, h+t-2, w-36, h-1,
+ 5, h-1, 4, h-2, 3, h-2, 1, h-4, 1, h-5, 0, h-6,
+ 0, 5];
+ tip.setLocation (Math.min (dest.width - size.x, x - size.x + i), y - size.y - t);
+ }
+ }
+ if ((style & DWT.BALLOON) !is 0) {
+ if (region !is null) region.dispose ();
+ region = new Region (display);
+ region.add (polyline);
+ tip.setRegion (region);
}
- }
- if ((style & DWT.BALLOON) !is 0) {
- if (region !is null) region.dispose ();
- region = new Region (display);
- region.add (polyline);
- tip.setRegion (region);
+ }
+
+ /**
+ * Returns true
if the receiver is automatically
+ * hidden by the platform, and false
otherwise.
+ *
+ * @return the receiver's auto hide state
+ *
+ * @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
+ *
+ *
+ */
+ public bool getAutoHide () {
+ checkWidget ();
+ return autohide;
}
-}
-
-/**
- * Returns true
if the receiver is automatically
- * hidden by the platform, and false
otherwise.
- *
- * @return the receiver's auto hide state
- *
- * @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
- *
- *
- */
-public bool getAutoHide () {
- checkWidget ();
- return autohide;
-}
-
-Point getSize (int maxWidth) {
- int textWidth = 0, messageWidth = 0;
- if (layoutText !is null) {
- layoutText.setWidth (-1);
- textWidth = layoutText.getBounds ().width;
+
+ Point getSize (int maxWidth) {
+ int textWidth = 0, messageWidth = 0;
+ if (layoutText !is null) {
+ layoutText.setWidth (-1);
+ textWidth = layoutText.getBounds ().width;
+ }
+ if (layoutMessage !is null) {
+ layoutMessage.setWidth (-1);
+ messageWidth = layoutMessage.getBounds ().width;
+ }
+ int messageTrim = 2 * INSET + 2 * BORDER + 2 * PADDING;
+ bool hasImage = layoutText !is null && (style & DWT.BALLOON) !is 0 && (style & (DWT.ICON_ERROR | DWT.ICON_INFORMATION | DWT.ICON_WARNING)) !is 0;
+ int textTrim = messageTrim + (hasImage ? IMAGE_SIZE : 0);
+ int width = Math.min (maxWidth, Math.max (textWidth + textTrim, messageWidth + messageTrim));
+ int textHeight = 0, messageHeight = 0;
+ if (layoutText !is null) {
+ layoutText.setWidth (maxWidth - textTrim);
+ textHeight = layoutText.getBounds ().height;
+ }
+ if (layoutMessage !is null) {
+ layoutMessage.setWidth (maxWidth - messageTrim);
+ messageHeight = layoutMessage.getBounds ().height;
+ }
+ int height = 2 * BORDER + 2 * PADDING + messageHeight;
+ if (layoutText !is null) height += Math.max (IMAGE_SIZE, textHeight) + 2 * PADDING;
+ return new Point (width, height);
}
- if (layoutMessage !is null) {
- layoutMessage.setWidth (-1);
- messageWidth = layoutMessage.getBounds ().width;
+
+ /**
+ * Returns the receiver's message, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's message
+ *
+ * @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
+ *
+ */
+ public String getMessage () {
+ checkWidget ();
+ return layoutMessage !is null ? layoutMessage.getText() : "";
}
- int messageTrim = 2 * INSET + 2 * BORDER + 2 * PADDING;
- bool hasImage = layoutText !is null && (style & DWT.BALLOON) !is 0 && (style & (DWT.ICON_ERROR | DWT.ICON_INFORMATION | DWT.ICON_WARNING)) !is 0;
- int textTrim = messageTrim + (hasImage ? IMAGE_SIZE : 0);
- int width = Math.min (maxWidth, Math.max (textWidth + textTrim, messageWidth + messageTrim));
- int textHeight = 0, messageHeight = 0;
- if (layoutText !is null) {
- layoutText.setWidth (maxWidth - textTrim);
- textHeight = layoutText.getBounds ().height;
+
+ /**
+ * Returns the receiver's parent, which must be a Shell
.
+ *
+ * @return the receiver's parent
+ *
+ * @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
+ *
+ */
+ public Shell getParent () {
+ checkWidget ();
+ return parent;
}
- if (layoutMessage !is null) {
- layoutMessage.setWidth (maxWidth - messageTrim);
- messageHeight = layoutMessage.getBounds ().height;
+
+ /**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @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
+ *
+ */
+ public String getText () {
+ checkWidget ();
+ return layoutText !is null ? layoutText.getText() : "";
}
- int height = 2 * BORDER + 2 * PADDING + messageHeight;
- if (layoutText !is null) height += Math.max (IMAGE_SIZE, textHeight) + 2 * PADDING;
- return new Point (width, height);
-}
-
-/**
- * Returns the receiver's message, which will be an empty
- * string if it has never been set.
- *
- * @return the receiver's message
- *
- * @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
- *
- */
-public String getMessage () {
- checkWidget ();
- return layoutMessage !is null ? layoutMessage.getText() : "";
-}
-
-/**
- * Returns the receiver's parent, which must be a Shell
.
- *
- * @return the receiver's parent
- *
- * @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
- *
- */
-public Shell getParent () {
- checkWidget ();
- return parent;
-}
-
-/**
- * Returns the receiver's text, which will be an empty
- * string if it has never been set.
- *
- * @return the receiver's text
- *
- * @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
- *
- */
-public String getText () {
- checkWidget ();
- return layoutText !is null ? layoutText.getText() : "";
-}
-
-/**
- * Returns true
if the receiver is visible, and
- * false
otherwise.
- *
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, this method
- * may still indicate that it is considered visible even though
- * it may not actually be showing.
- *
- *
- * @return the receiver's visibility state
- *
- * @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
- *
- */
-public bool getVisible () {
- checkWidget ();
- return tip.getVisible ();
-}
-
-/**
- * Returns true
if the receiver is visible and all
- * of the receiver's ancestors are visible and false
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @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 #getVisible
- */
-public bool isVisible () {
- checkWidget ();
- return getVisible ();
-}
-
-void onDispose (Event event) {
- removeListener (DWT.Dispose, listener);
- notifyListeners (DWT.Dispose, event);
- event.type = DWT.None;
-
- if (runnable !is null) {
- Display display = getDisplay ();
- display.timerExec (-1, runnable);
+
+ /**
+ * Returns true
if the receiver is visible, and
+ * false
otherwise.
+ *
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ *
+ *
+ * @return the receiver's visibility state
+ *
+ * @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
+ *
+ */
+ public bool getVisible () {
+ checkWidget ();
+ return tip.getVisible ();
+ }
+
+ /**
+ * Returns true
if the receiver is visible and all
+ * of the receiver's ancestors are visible and false
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @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 #getVisible
+ */
+ public bool isVisible () {
+ checkWidget ();
+ return getVisible ();
+ }
+
+ void onDispose (Event event) {
+ removeListener (DWT.Dispose, listener);
+ notifyListeners (DWT.Dispose, event);
+ event.type = DWT.None;
+
+ if (runnable !is null) {
+ Display display = getDisplay ();
+ display.timerExec (-1, runnable);
+ }
+ runnable = null;
+ tip.dispose ();
+ tip = null;
+ if (region !is null) region.dispose ();
+ region = null;
+ if (layoutText !is null) layoutText.dispose ();
+ layoutText = null;
+ if (layoutMessage !is null) layoutMessage.dispose ();
+ layoutMessage = null;
+ if (boldFont !is null) boldFont.dispose ();
+ boldFont = null;
+ borderPolygon = null;
+ }
+
+ void onMouseDown (Event event) {
+ notifyListeners (DWT.Selection, new Event ());
+ setVisible (false);
}
- runnable = null;
- tip.dispose ();
- tip = null;
- if (region !is null) region.dispose ();
- region = null;
- if (layoutText !is null) layoutText.dispose ();
- layoutText = null;
- if (layoutMessage !is null) layoutMessage.dispose ();
- layoutMessage = null;
- if (boldFont !is null) boldFont.dispose ();
- boldFont = null;
- borderPolygon = null;
-}
-
-void onMouseDown (Event event) {
- notifyListeners (DWT.Selection, new Event ());
- setVisible (false);
-}
-
-void onPaint (Event event) {
- GC gc = event.gc;
- int x = BORDER + PADDING;
- int y = BORDER + PADDING;
- if ((style & DWT.BALLOON) !is 0) {
- if (spikeAbove) y += TIP_HEIGHT;
- gc.drawPolygon (borderPolygon);
- } else {
- Rectangle rect = tip.getClientArea ();
- gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height -1);
- }
- if (layoutText !is null) {
- int id = style & (DWT.ICON_ERROR | DWT.ICON_INFORMATION | DWT.ICON_WARNING);
- if ((style & DWT.BALLOON) !is 0 && id !is 0) {
- Display display = getDisplay ();
- Image image = display.getSystemImage (id);
- Rectangle rect = image.getBounds ();
- gc.drawImage (image, 0, 0, rect.width, rect.height, x, y, IMAGE_SIZE, IMAGE_SIZE);
- x += IMAGE_SIZE;
+
+ void onPaint (Event event) {
+ GC gc = event.gc;
+ int x = BORDER + PADDING;
+ int y = BORDER + PADDING;
+ if ((style & DWT.BALLOON) !is 0) {
+ if (spikeAbove) y += TIP_HEIGHT;
+ gc.drawPolygon (borderPolygon);
+ } else {
+ Rectangle rect = tip.getClientArea ();
+ gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height -1);
+ }
+ if (layoutText !is null) {
+ int id = style & (DWT.ICON_ERROR | DWT.ICON_INFORMATION | DWT.ICON_WARNING);
+ if ((style & DWT.BALLOON) !is 0 && id !is 0) {
+ Display display = getDisplay ();
+ Image image = display.getSystemImage (id);
+ Rectangle rect = image.getBounds ();
+ gc.drawImage (image, 0, 0, rect.width, rect.height, x, y, IMAGE_SIZE, IMAGE_SIZE);
+ x += IMAGE_SIZE;
+ }
+ x += INSET;
+ layoutText.draw (gc, x, y);
+ y += 2 * PADDING + Math.max (IMAGE_SIZE, layoutText.getBounds ().height);
+ }
+ if (layoutMessage !is null) {
+ x = BORDER + PADDING + INSET;
+ layoutMessage.draw (gc, x, y);
}
- x += INSET;
- layoutText.draw (gc, x, y);
- y += 2 * PADDING + Math.max (IMAGE_SIZE, layoutText.getBounds ().height);
}
- if (layoutMessage !is null) {
- x = BORDER + PADDING + INSET;
- layoutMessage.draw (gc, x, y);
+
+ /**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver is selected by the user.
+ *
+ * @param listener the listener which should no longer 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 SelectionListener
+ * @see #addSelectionListener
+ */
+ public void removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+ if (eventTable is null) return;
+ eventTable.unhook (DWT.Selection, listener);
+ eventTable.unhook (DWT.DefaultSelection,listener);
+ }
+
+ /**
+ * Makes the receiver hide automatically when true
,
+ * and remain visible when false
.
+ *
+ * @param autoHide the auto hide state
+ *
+ * @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 #getVisible
+ * @see #setVisible
+ */
+ public void setAutoHide (bool autohide) {
+ checkWidget ();
+ this.autohide = autohide;
+ //TODO - update when visible
}
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver is selected by the user.
- *
- * @param listener the listener which should no longer 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 SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
- if (eventTable is null) return;
- eventTable.unhook (DWT.Selection, listener);
- eventTable.unhook (DWT.DefaultSelection,listener);
-}
-
-/**
- * Makes the receiver hide automatically when true
,
- * and remain visible when false
.
- *
- * @param autoHide the auto hide state
- *
- * @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 #getVisible
- * @see #setVisible
- */
-public void setAutoHide (bool autohide) {
- checkWidget ();
- this.autohide = autohide;
- //TODO - update when visible
-}
-
-/**
- * Sets the location of the receiver, which must be a tooltip,
- * to the point specified by the arguments which are relative
- * to the display.
- *
- * Note that this is different from most widgets where the
- * location of the widget is relative to the parent.
- *
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- *
- * @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
- *
- */
-public void setLocation (int x, int y) {
- checkWidget ();
- if (this.x is x && this.y is y) return;
- this.x = x;
- this.y = y;
- if (tip.getVisible ()) configure ();
-}
-
-/**
- * Sets the location of the receiver, which must be a tooltip,
- * to the point specified by the argument which is relative
- * to the display.
- *
- * Note that this is different from most widgets where the
- * location of the widget is relative to the parent.
- *
- * Note that the platform window manager ultimately has control
- * over the location of tooltips.
- *
- *
- * @param location the new location for the receiver
- *
- * @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the point 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
- *
- */
-public void setLocation (Point location) {
- checkWidget ();
- if (location is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
-}
-
-/**
- * Sets the receiver's message.
- *
- * @param string the new message
- *
- * @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the text 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
- *
- */
-public void setMessage (String string) {
- checkWidget ();
- if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
- if (layoutMessage !is null) layoutMessage.dispose();
- layoutMessage = null;
- if (string.length () !is 0) {
- Display display = getDisplay ();
- layoutMessage = new TextLayout (display);
- layoutMessage.setText (string);
+
+ /**
+ * Sets the location of the receiver, which must be a tooltip,
+ * to the point specified by the arguments which are relative
+ * to the display.
+ *
+ * Note that this is different from most widgets where the
+ * location of the widget is relative to the parent.
+ *
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @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
+ *
+ */
+ public void setLocation (int x, int y) {
+ checkWidget ();
+ if (this.x is x && this.y is y) return;
+ this.x = x;
+ this.y = y;
+ if (tip.getVisible ()) configure ();
+ }
+
+ /**
+ * Sets the location of the receiver, which must be a tooltip,
+ * to the point specified by the argument which is relative
+ * to the display.
+ *
+ * Note that this is different from most widgets where the
+ * location of the widget is relative to the parent.
+ *
+ * Note that the platform window manager ultimately has control
+ * over the location of tooltips.
+ *
+ *
+ * @param location the new location for the receiver
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the point 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
+ *
+ */
+ public void setLocation (Point location) {
+ checkWidget ();
+ if (location is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
}
- if (tip.getVisible ()) configure ();
-}
-
-/**
- * Sets the receiver's text.
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException
- * - ERROR_NULL_ARGUMENT - if the text 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
- *
- */
-public void setText (String string) {
- checkWidget ();
- if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
- if (layoutText !is null) layoutText.dispose ();
- layoutText = null;
- if (boldFont !is null) boldFont.dispose ();
- boldFont = null;
- if (string.length () !is 0) {
- Display display = getDisplay ();
- layoutText = new TextLayout (display);
- layoutText.setText (string);
- Font font = display.getSystemFont ();
- FontData data = font.getFontData () [0];
- boldFont = new Font (display, data.getName (), data.getHeight (), DWT.BOLD);
- TextStyle style = new TextStyle (boldFont, null, null);
- layoutText.setStyle (style, 0, string.length ());
+
+ /**
+ * Sets the receiver's message.
+ *
+ * @param string the new message
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the text 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
+ *
+ */
+ public void setMessage (String string) {
+ checkWidget ();
+ if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+ if (layoutMessage !is null) layoutMessage.dispose();
+ layoutMessage = null;
+ if (string.length () !is 0) {
+ Display display = getDisplay ();
+ layoutMessage = new TextLayout (display);
+ layoutMessage.setText (string);
+ }
+ if (tip.getVisible ()) configure ();
}
- if (tip.getVisible ()) configure ();
-}
-
-/**
- * Marks the receiver as visible if the argument is true
,
- * and marks it invisible otherwise.
- *
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, marking
- * it visible may not actually cause it to be displayed.
- *
- *
- * @param visible the new visibility state
- *
- * @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
- *
- */
-public void setVisible (bool visible) {
- if (visible) configure ();
- tip.setVisible (visible);
- Display display = getDisplay ();
- if (runnable !is null) display.timerExec (-1, runnable);
- runnable = null;
- if (autohide && visible) {
- runnable = new class Runnable {
- public void run () {
- if (!isDisposed ()) setVisible (false);
- }
- };
- display.timerExec(DELAY, runnable);
+
+ /**
+ * Sets the receiver's text.
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the text 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
+ *
+ */
+ public void setText (String string) {
+ checkWidget ();
+ if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+ if (layoutText !is null) layoutText.dispose ();
+ layoutText = null;
+ if (boldFont !is null) boldFont.dispose ();
+ boldFont = null;
+ if (string.length () !is 0) {
+ Display display = getDisplay ();
+ layoutText = new TextLayout (display);
+ layoutText.setText (string);
+ Font font = display.getSystemFont ();
+ FontData data = font.getFontData () [0];
+ boldFont = new Font (display, data.getName (), data.getHeight (), DWT.BOLD);
+ TextStyle style = new TextStyle (boldFont, null, null);
+ layoutText.setStyle (style, 0, string.length ());
+ }
+ if (tip.getVisible ()) configure ();
}
-}
-
-}
+
+ /**
+ * Marks the receiver as visible if the argument is true
,
+ * and marks it invisible otherwise.
+ *
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ *
+ *
+ * @param visible the new visibility state
+ *
+ * @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
+ *
+ */
+ public void setVisible (bool visible) {
+ if (visible) configure ();
+ tip.setVisible (visible);
+ Display display = getDisplay ();
+ if (runnable !is null) display.timerExec (-1, runnable);
+ runnable = null;
+ if (autohide && visible) {
+ runnable = new class Runnable {
+ public void run () {
+ if (!isDisposed ()) setVisible (false);
+ }
+ };
+ display.timerExec(DELAY, runnable);
+ }
+ }
+
+ }
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Tray.d
--- a/dwt/widgets/Tray.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Tray.d Fri Oct 10 12:29:48 2008 +0200
@@ -42,7 +42,7 @@
*/
public class Tray : Widget {
int itemCount;
- TrayItem [] items = new TrayItem [4];
+ TrayItem [] items;
this (Display display, int style) {
if (display is null) display = Display.getCurrent ();
@@ -51,6 +51,7 @@
error (DWT.ERROR_THREAD_INVALID_ACCESS);
}
this.display = display;
+ items = new TrayItem [4];
}
void createItem (TrayItem item, int index) {
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/TrayItem.d
--- a/dwt/widgets/TrayItem.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/TrayItem.d Fri Oct 10 12:29:48 2008 +0200
@@ -7,6 +7,9 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ *
+ * Port to the D programming language:
+ * Jacob Carlborg
*******************************************************************************/
module dwt.widgets.TrayItem;
@@ -29,7 +32,7 @@
import dwt.internal.cocoa.SWTImageView;
import dwt.dwthelper.utils;
-
+import dwt.internal.cocoa.NSView;
import dwt.widgets.Item;
import dwt.widgets.ToolTip;
import dwt.widgets.Tray;
@@ -168,7 +171,7 @@
if (item is null) error (DWT.ERROR_NO_HANDLES);
item.retain();
item.setHighlightMode(true);
- NSRect rect = new NSRect();
+ NSRect rect = NSRect();
view = cast(NSImageView)(new SWTImageView()).alloc();
if (view is null) error (DWT.ERROR_NO_HANDLES);
view.initWithFrame(rect);
@@ -185,7 +188,7 @@
Point getLocation () {
NSRect rect = view.frame();
NSRect windowRect = view.window().frame();
- NSPoint pt = new NSPoint();
+ NSPoint pt = NSPoint();
pt.x = rect.width / 2;
pt.y = rect.height;
pt = view.convertPoint_fromView_(pt, null);
@@ -429,14 +432,14 @@
_setToolTipText (toolTipText);
}
-void mouseDown(int event) {
+void mouseDown(objc.id event) {
NSEvent nsEvent = new NSEvent(event);
int mask = nsEvent.modifierFlags() & OS.NSDeviceIndependentModifierFlagsMask;
if (mask is OS.NSControlKeyMask) {
showMenu();
} else {
highlight = true;
- view.setNeedsDisplay(true);
+ (cast(NSView)view).setNeedsDisplay(true);
int clickCount = nsEvent.clickCount();
postEvent(clickCount is 2 ? DWT.DefaultSelection : DWT.Selection);
}
@@ -444,14 +447,14 @@
void mouseUp(int event) {
highlight = false;
- view.setNeedsDisplay(true);
+ (cast(NSView)view).setNeedsDisplay(true);
}
void rightMouseDown(int event) {
showMenu();
}
-void drawRect(int id, NSRect rect) {
+void drawRect(objc.id id, NSRect rect) {
item.drawStatusBarBackgroundInRect(rect, highlight);
super.drawRect(id, rect);
}
diff -r db5a898b2119 -r 642f460a0908 dwt/widgets/Widget.d
--- a/dwt/widgets/Widget.d Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Widget.d Fri Oct 10 12:29:48 2008 +0200
@@ -146,11 +146,11 @@
display = parent.display;
}
-void callSuper(objc.id id, int selector, int arg0) {
+void callSuper(objc.id id, String selector, objc.id arg0) {
objc_super super_struct;
super_struct.receiver = id;
- super_struct.cls = OS.objc_msgSend(id, OS.sel_superclass);
- OS.objc_msgSendSuper(super_struct, selector, arg0);
+ super_struct.cls = cast(objc.Class) OS.objc_msgSend(id, OS.sel_superclass);
+ OS.objc_msgSendSuper(&super_struct, selector, arg0);
}
bool acceptsFirstResponder () {
@@ -314,7 +314,7 @@
* ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*
*/
-protected void checkWidget () {
+public void checkWidget () {
Display display = this.display;
if (display is null) error (DWT.ERROR_WIDGET_DISPOSED);
if (display.thread !is Thread.getThis ()) error (DWT.ERROR_THREAD_INVALID_ACCESS);
@@ -331,13 +331,13 @@
void createHandle () {
}
-/*void createJNIRef () {
+void createJNIRef () {
jniRef = OS.NewGlobalRef(this);
if (jniRef is 0) error (DWT.ERROR_NO_HANDLES);
-}*/
+}
void createWidget () {
- //createJNIRef ();
+ createJNIRef ();
createHandle ();
}
@@ -385,8 +385,8 @@
void drawRect(objc.id id, NSRect rect) {
objc_super super_struct;
super_struct.receiver = id;
- super_struct.cls = OS.objc_msgSend(id, OS.sel_superclass);
- OS.objc_msgSendSuper(super_struct, OS.sel_drawRect_1, rect);
+ super_struct.cls = cast(objc.Class) OS.objc_msgSend(id, OS.sel_superclass);
+ OS.objc_msgSendSuper(&super_struct, OS.sel_drawRect_1, rect);
}
void drawWidget (int control, int context, int damageRgn, int visibleRgn, int theEvent) {
@@ -613,7 +613,7 @@
}
bool isValidSubclass () {
- return Display.isValidClass (getClass ());
+ return Display.isValidClass (this.classinfo);
}
bool isValidThread () {
@@ -751,8 +751,8 @@
void releaseHandle () {
state |= DISPOSED;
display = null;
- //if (jniRef !is 0) OS.DeleteGlobalRef(jniRef);
- //jniRef = 0;
+ if (jniRef !is 0) OS.DeleteGlobalRef(jniRef);
+ jniRef = 0;
}
void releaseParent () {
@@ -963,10 +963,10 @@
*/
public void setData (Object data) {
checkWidget();
- if (SAFARI_EVENTS_FIX_KEY.equals (data)) {
+ /*if (SAFARI_EVENTS_FIX_KEY.equals (data)) {
state |= SAFARI_EVENTS_FIX;
return;
- }
+ }*/
if ((state & KEYED_DATA) !is 0) {
(cast(ArrayWrapperObject) this.data).array [0] = data;
} else {
@@ -1006,7 +1006,8 @@
if ((state & KEYED_DATA) !is 0) {
table = (cast(ArrayWrapperObject) data).array;
while (index < table.length) {
- if (key.equals (table [index])) break;
+ String tablekey = (cast(ArrayWrapperString)table[index]).array;
+ if (key.equals (tablekey)) break;
index += 2;
}
}
@@ -1015,15 +1016,16 @@
if (index is table.length) {
Object [] newTable = new Object [table.length + 2];
System.arraycopy (table, 0, newTable, 0, table.length);
- data = table = newTable;
+ table = newTable;
+ data = new ArrayWrapperObject( table );
}
} else {
table = new Object [3];
table [0] = data;
- data = table;
+ data = new ArrayWrapperObject( table );
state |= KEYED_DATA;
}
- table [index] = key;
+ table [index] = new ArrayWrapperString( key );
table [index + 1] = value;
} else {
if ((state & KEYED_DATA) !is 0) {
@@ -1036,7 +1038,7 @@
Object [] newTable = new Object [length];
System.arraycopy (table, 0, newTable, 0, index);
System.arraycopy (table, index + 2, newTable, index, length - index);
- data = newTable;
+ data = new ArrayWrapperObject( newTable );
}
}
}
@@ -1251,7 +1253,7 @@
string = "*Wrong Thread*";
if (isValidThread ()) string = getNameText ();
}
- return getName () + " {" + string + "}";
+ return getName () ~ " {" ~ string ~ "}";
}
void willSelectTabViewItem(int tabView, int tabViewItem) {
@@ -1270,7 +1272,7 @@
}
void windowSendEvent(objc.id id, objc.id event) {
- callSuper(objc.id, OS.sel_sendEvent_1, event);
+ callSuper(id, OS.sel_sendEvent_1, event);
}
bool windowShouldClose(int window) {