# HG changeset patch # User Jacob Carlborg # Date 1228769186 -3600 # Node ID 6309d49b16b721f4b0b99d0405fac970293b74a5 # Parent 96d20dc95b8c0d4c358bd78fdaee53e3076f3a79 Updated IME to 3.514 diff -r 96d20dc95b8c -r 6309d49b16b7 dwt/internal/cocoa/NSRange.d --- a/dwt/internal/cocoa/NSRange.d Mon Dec 08 21:27:18 2008 +0100 +++ b/dwt/internal/cocoa/NSRange.d Mon Dec 08 21:46:26 2008 +0100 @@ -14,7 +14,7 @@ module dwt.internal.cocoa.NSRange; import dwt.dwthelper.utils; -import dwt.internal.cocoa.NSInteger; +import dwt.internal.objc.cocoa.Cocoa; alias NSRange* NSRangePointer; diff -r 96d20dc95b8c -r 6309d49b16b7 dwt/widgets/IME.d --- a/dwt/widgets/IME.d Mon Dec 08 21:27:18 2008 +0100 +++ b/dwt/widgets/IME.d Mon Dec 08 21:46:26 2008 +0100 @@ -33,8 +33,11 @@ import dwt.internal.cocoa.OS; import dwt.dwthelper.utils; +import dwt.internal.c.Carbon; import dwt.internal.objc.cocoa.Cocoa; import dwt.widgets.Canvas; +import dwt.widgets.Caret; +import dwt.widgets.Event; import dwt.widgets.Widget; /** @@ -111,13 +114,13 @@ Event event = new Event (); event.detail = DWT.COMPOSITION_SELECTION; sendEvent (DWT.ImeComposition, event); - NSRange range = new NSRange (); - OS.memmove (range, rangePtr, NSRange.sizeof); - int start = (int)/*64*/range.location; - int end = (int)/*64*/(range.location + range.length); + NSRange range = NSRange (); + OS.memmove (&range, rangePtr, NSRange.sizeof); + int start = cast(int)/*64*/range.location; + int end = cast(int)/*64*/(range.location + range.length); if (event.start <= start && start <= event.end && event.start <= end && end <= event.end) { NSString str = NSString.stringWith (event.text.substring(start - event.start, end - event.start)); - NSAttributedString attriStr = ((NSAttributedString)new NSAttributedString().alloc()).initWithString(str, null); + NSAttributedString attriStr = (cast(NSAttributedString)(new NSAttributedString()).alloc()).initWithString(str, null); attriStr.autorelease (); return attriStr.id; } @@ -126,17 +129,17 @@ NSInteger characterIndexForPoint (objc.id id, objc.SEL sel, objc.id point) { if (!isInlineEnabled ()) return OS.NSNotFound; - NSPoint pt = new NSPoint (); - OS.memmove (pt, point, NSPoint.sizeof); + NSPoint pt = NSPoint (); + OS.memmove (&pt, point, NSPoint.sizeof); NSView view = parent.view; pt = view.window ().convertScreenToBase (pt); pt = view.convertPoint_fromView_ (pt, null); Event event = new Event (); event.detail = DWT.COMPOSITION_OFFSET; - event.x = (int) pt.x; - event.y = (int) pt.y; + event.x = cast(int) pt.x; + event.y = cast(int) pt.y; sendEvent (DWT.ImeComposition, event); - int offset = event.index + event.count; + NSInteger offset = event.index + event.count; return offset !is -1 ? offset : OS.NSNotFound; } @@ -149,11 +152,11 @@ } NSRect firstRectForCharacterRange(objc.id id, objc.SEL sel, objc.id range) { - NSRect rect = new NSRect (); + NSRect rect = NSRect (); Caret caret = parent.caret; if (caret !is null) { NSView view = parent.view; - NSPoint pt = new NSPoint (); + NSPoint pt = NSPoint (); pt.x = caret.x; pt.y = caret.y + caret.height; pt = view.convertPoint_toView_ (pt, null); @@ -276,21 +279,21 @@ TextStyle getStyle (NSDictionary attribs) { NSArray keys = attribs.allKeys (); - int /*long*/ count = keys.count (); + NSUInteger count = keys.count (); TextStyle style = new TextStyle (); - for (int j = 0; j < count; j++) { + for (NSUInteger j = 0; j < count; j++) { NSString key = new NSString (keys.objectAtIndex (j)); if (key.isEqualTo (OS.NSBackgroundColorAttributeName)) { - NSColor color = new NSColor (attribs.objectForKey (key)).colorUsingColorSpaceName (OS.NSCalibratedRGBColorSpace); - float [] rgbColor = new float []{(float)/*64*/color.redComponent(), (float)/*64*/color.greenComponent(), (float)/*64*/color.blueComponent(), (float)/*64*/color.alphaComponent()}; + NSColor color = (new NSColor (attribs.objectForKey (key))).colorUsingColorSpaceName (OS.NSCalibratedRGBColorSpace); + CGFloat [] rgbColor = [color.redComponent(), color.greenComponent(), color.blueComponent(), color.alphaComponent()]; style.background = Color.cocoa_new (display, rgbColor); } else if (key.isEqualTo (OS.NSForegroundColorAttributeName)) { - NSColor color = new NSColor (attribs.objectForKey (key)).colorUsingColorSpaceName (OS.NSCalibratedRGBColorSpace); - float [] rgbColor = new float []{(float)/*64*/color.redComponent(), (float)/*64*/color.greenComponent(), (float)/*64*/color.blueComponent(), (float)/*64*/color.alphaComponent()}; + NSColor color = (new NSColor (attribs.objectForKey (key))).colorUsingColorSpaceName (OS.NSCalibratedRGBColorSpace); + CGFloat [] rgbColor = [color.redComponent(), color.greenComponent(), color.blueComponent(), color.alphaComponent()]; style.foreground = Color.cocoa_new (display, rgbColor); } else if (key.isEqualTo (OS.NSUnderlineColorAttributeName)) { - NSColor color = new NSColor (attribs.objectForKey (key)).colorUsingColorSpaceName (OS.NSCalibratedRGBColorSpace); - float [] rgbColor = new float []{(float)/*64*/color.redComponent(), (float)/*64*/color.greenComponent(), (float)/*64*/color.blueComponent(), (float)/*64*/color.alphaComponent()}; + NSColor color = (new NSColor (attribs.objectForKey (key))).colorUsingColorSpaceName (OS.NSCalibratedRGBColorSpace); + CGFloat [] rgbColor = [color.redComponent(), color.greenComponent(), color.blueComponent(), color.alphaComponent()]; style.underlineColor = Color.cocoa_new (display, rgbColor); } else if (key.isEqualTo (OS.NSUnderlineStyleAttributeName)) { NSNumber value = new NSNumber (attribs.objectForKey (key)); @@ -298,11 +301,13 @@ case OS.NSUnderlineStyleSingle: style.underlineStyle = DWT.UNDERLINE_SINGLE; break; case OS.NSUnderlineStyleDouble: style.underlineStyle = DWT.UNDERLINE_DOUBLE; break; case OS.NSUnderlineStyleThick: style.underlineStyle = UNDERLINE_THICK; break; + default: + assert(false); } style.underline = value.intValue () !is OS.NSUnderlineStyleNone; } else if (key.isEqualTo (OS.NSStrikethroughColorAttributeName)) { - NSColor color = new NSColor (attribs.objectForKey (key)).colorUsingColorSpaceName (OS.NSCalibratedRGBColorSpace); - float [] rgbColor = new float []{(float)/*64*/color.redComponent(), (float)/*64*/color.greenComponent(), (float)/*64*/color.blueComponent(), (float)/*64*/color.alphaComponent()}; + NSColor color = (new NSColor (attribs.objectForKey (key))).colorUsingColorSpaceName (OS.NSCalibratedRGBColorSpace); + CGFloat [] rgbColor = [color.redComponent(), color.greenComponent(), color.blueComponent(), color.alphaComponent()]; style.strikeoutColor = Color.cocoa_new (display, rgbColor); } else if (key.isEqualTo (OS.NSStrikethroughStyleAttributeName)) { NSNumber value = new NSNumber (attribs.objectForKey (key)); @@ -391,7 +396,7 @@ sendEvent (DWT.ImeComposition, event); startOffset = event.start; } - NSRange range = new NSRange (); + NSRange range = NSRange (); range.location = startOffset; range.length = text.length (); return range; @@ -414,7 +419,7 @@ Event event = new Event (); event.detail = DWT.COMPOSITION_SELECTION; sendEvent (DWT.ImeComposition, event); - NSRange range = new NSRange (); + NSRange range = NSRange (); range.location = event.start; range.length = event.text.length (); return range; @@ -461,19 +466,19 @@ if (str.isKindOfClass (OS.objc_getClass ("NSAttributedString"))) { NSAttributedString attribStr = new NSAttributedString (string); str = attribStr.string (); - int length = (int)/*64*/str.length (); + NSUInteger length = str.length (); styles = new TextStyle [length]; ranges = new int [length * 2]; - NSRange rangeLimit = new NSRange (), effectiveRange = new NSRange (); + NSRange rangeLimit = NSRange (), effectiveRange = NSRange (); rangeLimit.length = length; int rangeCount = 0; - int /*long*/ ptr = OS.malloc (NSRange.sizeof); - for (int i = 0; i < length;) { + NSRangePointer ptr = OS.malloc (NSRange.sizeof); + for (NSUInteger i = 0; i < length;) { NSDictionary attribs = attribStr.attributesAtIndex(i, ptr, rangeLimit); OS.memmove (effectiveRange, ptr, NSRange.sizeof); - i = (int)/*64*/(effectiveRange.location + effectiveRange.length); - ranges [rangeCount * 2] = (int)/*64*/effectiveRange.location; - ranges [rangeCount * 2 + 1] = (int)/*64*/(effectiveRange.location + effectiveRange.length - 1); + i = effectiveRange.location + effectiveRange.length; + ranges [rangeCount * 2] = cast(int)/*64*/effectiveRange.location; + ranges [rangeCount * 2 + 1] = cast(int)/*64*/(effectiveRange.location + effectiveRange.length - 1); styles [rangeCount++] = getStyle (attribs); } OS.free (ptr); @@ -486,14 +491,14 @@ ranges = newRanges; } } - int length = (int)/*64*/str.length (); + NSUInteger length = str.length (); if (ranges is null && length > 0) { - styles = new TextStyle []{getStyle (display.markedAttributes)}; - ranges = new int[]{0, length - 1}; + styles = [getStyle (display.markedAttributes)]; + ranges = [0, length - 1]; } - NSRange range = new NSRange (); + NSRange range = NSRange (); OS.memmove (range, selRange, NSRange.sizeof); - caretOffset = (int)/*64*/range.location; + caretOffset = cast(int)/*64*/range.location; Event event = new Event (); event.detail = DWT.COMPOSITION_CHANGED; event.start = startOffset;