# HG changeset patch # User Jacob Carlborg # Date 1230659671 -3600 # Node ID c7f7f4d7091abb6dc14e5e77e8a6d5b53d6ff155 # Parent 8e3c85e1733d30fcdf0b970e6e464f2fc9b56130 All widgets are ported diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/dwthelper/utils.d Tue Dec 30 18:54:31 2008 +0100 @@ -530,6 +530,12 @@ static alias CharacterIsLetterOrDigit isLetterOrDigit; static alias CharacterIsSpaceChar isSpaceChar; static alias CharacterIsWhitespace isWhitespace; + static alias CharacterIsDigit isDigit; + + static T toLowerCase (T)(T c) + { + return tango.text.Unicode.toLower([c])[0]; + } } String new_String( String cont, int offset, int len ){ diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/internal/cocoa/NSBox.d --- a/dwt/internal/cocoa/NSBox.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/internal/cocoa/NSBox.d Tue Dec 30 18:54:31 2008 +0100 @@ -36,16 +36,6 @@ NSBoxCustom = 4 } -enum NSTitlePosition { - NSNoTitle = 0, - NSAboveTop = 1, - NSAtTop = 2, - NSBelowTop = 3, - NSAboveBottom = 4, - NSAtBottom = 5, - NSBelowBottom = 6 -} - public class NSBox : NSView { public this () { diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/internal/cocoa/NSImageCell.d --- a/dwt/internal/cocoa/NSImageCell.d Tue Dec 30 17:01:10 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -/** - * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved. - * Authors: Jacob Carlborg - * Version: Initial created: Nov 28, 2008 - * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style) - * - */ -module dwt.internal.cocoa.NSImageCell; - -enum NSImageAlignment -{ - NSImageAlignCenter = 0, - NSImageAlignTop, - NSImageAlignTopLeft, - NSImageAlignTopRight, - NSImageAlignLeft, - NSImageAlignBottom, - NSImageAlignBottomLeft, - NSImageAlignBottomRight, - NSImageAlignRight -} \ No newline at end of file diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/internal/cocoa/NSImageView.d --- a/dwt/internal/cocoa/NSImageView.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/internal/cocoa/NSImageView.d Tue Dec 30 18:54:31 2008 +0100 @@ -18,7 +18,6 @@ import dwt.internal.cocoa.NSCell; import dwt.internal.cocoa.NSControl; import dwt.internal.cocoa.NSImage; -import dwt.internal.cocoa.NSImageCell; import dwt.internal.cocoa.OS; import dwt.internal.objc.cocoa.Cocoa; import objc = dwt.internal.objc.runtime; diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/internal/cocoa/OS.d --- a/dwt/internal/cocoa/OS.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/internal/cocoa/OS.d Tue Dec 30 18:54:31 2008 +0100 @@ -57,6 +57,7 @@ import dwt.internal.cocoa.NSGradient; import dwt.internal.cocoa.NSGraphicsContext; import dwt.internal.cocoa.NSImage; +import dwt.internal.cocoa.NSNumberFormatter; import dwt.internal.cocoa.NSParagraphStyle; import dwt.internal.cocoa.NSPoint; import dwt.internal.cocoa.NSRange; @@ -65,6 +66,7 @@ import dwt.internal.cocoa.NSScroller; import dwt.internal.cocoa.NSSize; import dwt.internal.cocoa.NSString; +import dwt.internal.cocoa.NSTabView; import dwt.internal.cocoa.NSTableView; import dwt.internal.cocoa.NSText; import dwt.internal.cocoa.NSView; @@ -2739,7 +2741,7 @@ public static const int NSApplicationDelegateReplySuccess = 0; public static const int NSAscendingPageOrder = 1; public static const int NSAtBottom = 5; -alias NSTitlePosition.NSAtTop NSAtTop; +alias Cocoa.NSTitlePosition.NSAtTop NSAtTop; public static const int NSAttachmentCharacter = 65532; public static const int NSAutoPagination = 0; public static const int NSAutosaveOperation = 3; @@ -2763,7 +2765,7 @@ public static const int NSBlueControlTint = 1; public static const int NSBoldFontMask = 2; alias Cocoa.NSBorderlessWindowMask NSBorderlessWindowMask; -public static const int NSBottomTabsBezelBorder = 2; +alias NSTabViewType.NSBottomTabsBezelBorder NSBottomTabsBezelBorder; public static const int NSBoxCustom = 4; public static const int NSBoxOldStyle = 3; public static const int NSBoxPrimary = 0; @@ -2817,7 +2819,7 @@ public static const int NSClearDisplayFunctionKey = 63290; public static const int NSClearLineFunctionKey = 63289; public static const int NSClipPagination = 2; -public static const int NSClockAndCalendarDatePickerStyle = 1; +alias NSDatePickerStyle.NSClockAndCalendarDatePickerStyle NSClockAndCalendarDatePickerStyle; public static const int NSClosableWindowMask = 2; alias Cocoa.NSBezierPathElement.NSClosePathBezierPathElement NSClosePathBezierPathElement; public static const int NSColorListModeColorPanel = 5; @@ -3050,12 +3052,12 @@ public static const int NSIdentityMappingCharacterCollection = 0; public static const int NSIllegalTextMovement = 0; alias Cocoa.NSCellImagePosition.NSImageAbove NSImageAbove; -public static const int NSImageAlignBottom = 5; -public static const int NSImageAlignBottomLeft = 6; -public static const int NSImageAlignBottomRight = 7; -public static const int NSImageAlignCenter = 0; -public static const int NSImageAlignLeft = 4; -public static const int NSImageAlignRight = 8; +alias Cocoa.NSImageAlignment.NSImageAlignBottom NSImageAlignBottom; +alias Cocoa.NSImageAlignment.NSImageAlignBottomLeft NSImageAlignBottomLeft; +alias Cocoa.NSImageAlignment.NSImageAlignBottomRight NSImageAlignBottomRight; +alias Cocoa.NSImageAlignment.NSImageAlignCenter NSImageAlignCenter; +alias Cocoa.NSImageAlignment.NSImageAlignLeft NSImageAlignLeft; +alias Cocoa.NSImageAlignment.NSImageAlignRight NSImageAlignRight; public static const int NSImageAlignTop = 1; public static const int NSImageAlignTopLeft = 2; public static const int NSImageAlignTopRight = 3; @@ -3181,7 +3183,7 @@ public static const int NSNoTabsBezelBorder = 4; public static const int NSNoTabsLineBorder = 5; public static const int NSNoTabsNoBorder = 6; -alias NSTitlePosition.NSNoTitle NSNoTitle; +alias Cocoa.NSTitlePosition.NSNoTitle NSNoTitle; public static const int NSNoUnderlineStyle = 0; public static const int NSNonStandardCharacterSetFontMask = 8; alias Cocoa.NSWindingRule.NSNonZeroWindingRule NSNonZeroWindingRule; @@ -3351,7 +3353,7 @@ public static const int NSSaveAsOperation = 1; public static const int NSSaveOperation = 0; public static const int NSSaveToOperation = 2; -public static const int NSScaleNone = 2; +alias Cocoa.NSImageScaling.NSImageScaleNone NSScaleNone; public static const int NSScaleProportionally = 0; public static const int NSScaleToFit = 1; public static const int NSScreenChangedEventType = 8; @@ -3861,7 +3863,7 @@ public static const int NSNumberFormatterBehavior10_4 = 1040; public static const int NSNumberFormatterBehaviorDefault = 0; public static const int NSNumberFormatterCurrencyStyle = 2; -public static const int NSNumberFormatterDecimalStyle = 1; +alias NSNumberFormatterStyle.NSNumberFormatterDecimalStyle NSNumberFormatterDecimalStyle; public static const int NSNumberFormatterNoStyle = 0; public static const int NSNumberFormatterPadAfterPrefix = 1; public static const int NSNumberFormatterPadAfterSuffix = 3; diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/internal/objc/cocoa/Cocoa.d --- a/dwt/internal/objc/cocoa/Cocoa.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/internal/objc/cocoa/Cocoa.d Tue Dec 30 18:54:31 2008 +0100 @@ -214,6 +214,20 @@ +// NSBox.h +enum NSTitlePosition +{ + NSNoTitle = 0, + NSAboveTop = 1, + NSAtTop = 2, + NSBelowTop = 3, + NSAboveBottom = 4, + NSAtBottom = 5, + NSBelowBottom = 6 +} + + + // NSButtonCell.h enum NSBezelStyle : NSUInteger { NSRoundedBezelStyle = 1, @@ -416,6 +430,22 @@ +// NSImageCell.h +enum NSImageAlignment +{ + NSImageAlignCenter = 0, + NSImageAlignTop, + NSImageAlignTopLeft, + NSImageAlignTopRight, + NSImageAlignLeft, + NSImageAlignBottom, + NSImageAlignBottomLeft, + NSImageAlignBottomRight, + NSImageAlignRight +} + + + // NSBitmapImageRep.h enum NSTIFFCompression : NSUInteger { NSTIFFCompressionNone = 1, diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/Combo.d --- a/dwt/widgets/Combo.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/Combo.d Tue Dec 30 18:54:31 2008 +0100 @@ -44,9 +44,10 @@ import dwt.internal.cocoa.SWTComboBox; import dwt.internal.cocoa.SWTPopUpButton; -import dwt.internal.c.Carbon; +import Carbon = dwt.internal.c.Carbon; import objc = dwt.internal.objc.runtime; import dwt.widgets.Composite; +import dwt.widgets.Event; import dwt.widgets.TypedListener; /** @@ -88,9 +89,10 @@ * @see Sample code and further information */ public class Combo : Composite { - int textLimit = LIMIT; + int textLimit; bool receivingFocus; - NSRange selectionRange; + NSRange* selectionRange; + NSRange selectionRangeStruct; /** * the operating system limit for the number of characters @@ -140,6 +142,7 @@ */ public this (Composite parent, int style) { super (parent, checkStyle (style)); + textLimit = LIMIT; } /** @@ -363,7 +366,7 @@ } } -void comboBoxSelectionDidChange(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { +void comboBoxSelectionDidChange(objc.id id, objc.SEL sel, objc.id notification) { sendSelection(); } @@ -458,7 +461,7 @@ char [] buffer = new char [oldText.length ()]; oldText.getChars (0, buffer.length, buffer, 0); copyToClipboard (buffer); - setText (leftText + newText + rightText, false); + setText (leftText ~ newText ~ rightText, false); start += newText.length (); setSelection (new Point (start, start)); sendEvent (DWT.Modify); @@ -717,14 +720,14 @@ return new_String (getText(0, -1)); } -wchar [] getText (int start, int end) { +char [] getText (int start, int end) { NSString str; if ((style & DWT.READ_ONLY) !is 0) { str = (cast(NSPopUpButton)view).titleOfSelectedItem(); } else { str = (new NSCell((cast(NSComboBox)view).cell())).title(); } - if (str is null) return new wchar[0]; + if (str is null) return new char[0]; NSRange range = NSRange (); range.location = start; if (end is -1) { @@ -733,8 +736,8 @@ } else { range.length = end - start; } - wchar [] buffer= new wchar [range.length]; - str.getCharacters(buffer.ptr, range); + char [] buffer= new char [range.length]; + str.getCharacters(buffer.toString16().ptr, range); return buffer; } @@ -854,18 +857,18 @@ } void insertEditText (String string) { - NSUInteger length = string.length (); + NSUInteger length_ = string.length (); Point selection = getSelection (); if (hasFocus ()) { if (textLimit !is LIMIT) { int charCount = getCharCount(); - if (charCount - (selection.y - selection.x) + length > textLimit) { - length = textLimit - charCount + (selection.y - selection.x); + if (charCount - (selection.y - selection.x) + length_ > textLimit) { + length_ = textLimit - charCount + (selection.y - selection.x); } } - wchar [] buffer = new wchar [length]; + char [] buffer = new char [length_]; string.getChars (0, buffer.length, buffer, 0); - NSString nsstring = NSString.stringWithCharacters (buffer.ptr, buffer.length); + NSString nsstring = NSString.stringWithCharacters (buffer.toString16().ptr, buffer.length); NSText editor = (cast(NSTextField) view).currentEditor (); editor.replaceCharactersInRange (editor.selectedRange (), nsstring); selectionRange = null; @@ -873,11 +876,11 @@ String oldText = getText (); if (textLimit !is LIMIT) { int charCount = oldText.length (); - if (charCount - (selection.y - selection.x) + length > textLimit) { + if (charCount - (selection.y - selection.x) + length_ > textLimit) { string = string.substring(0, textLimit - charCount + (selection.y - selection.x)); } } - String newText = oldText.substring (0, selection.x) + string + oldText.substring (selection.y); + String newText = oldText.substring (0, selection.x) ~ string ~ oldText.substring (selection.y); NSString nsstring = NSString.stringWith(newText); (new NSCell ((cast(NSTextField) view).cell ())).setTitle (nsstring); selectionRange = null; @@ -918,7 +921,7 @@ newText = newText.substring(0, textLimit - charCount + (end - start)); } } - setText (leftText + newText + rightText, false); + setText (leftText ~ newText ~ rightText, false); start += newText.length (); setSelection (new Point (start, start)); sendEvent (DWT.Modify); @@ -1263,7 +1266,7 @@ return result; } -void setBackground (CGFloat [] color) { +void setBackground (Carbon.CGFloat [] color) { NSColor nsColor; if (color is null) { return; // TODO reset to OS default @@ -1295,7 +1298,7 @@ super.setBounds (x, y, width, height, move, resize); } -void setForeground (CGFloat [] color) { +void setForeground (Carbon.CGFloat [] color) { NSColor nsColor; if (color is null) { return; // TODO reset to OS default @@ -1445,12 +1448,13 @@ NSUInteger length = str.length(); NSUInteger start = Math.min (Math.max (Math.min (selection.x, selection.y), 0), length); NSUInteger end = Math.min (Math.max (Math.max (selection.x, selection.y), 0), length); - selectionRange = NSRange(); + selectionRangeStruct = NSRange(); + selectionRange = &selectionRangeStruct; selectionRange.location = start; selectionRange.length = end - start; if (this is display.getFocusControl ()) { NSText editor = view.window().fieldEditor(false, view); - editor.setSelectedRange(selectionRange); + editor.setSelectedRange(selectionRangeStruct); } } } @@ -1558,7 +1562,7 @@ void textViewDidChangeSelection(objc.id id, objc.SEL sel, objc.id aNotification) { NSNotification notification = new NSNotification(aNotification); NSText editor = new NSText(notification.object().id); - selectionRange = editor.selectedRange(); + selectionRangeStruct = editor.selectedRange(); } void textDidChange (objc.id id, objc.SEL sel, objc.id aNotification) { @@ -1571,7 +1575,7 @@ * then return the receiver's last selection range, otherwise the full * text will be automatically selected. */ - if (receivingFocus && selectionRange !is null) return selectionRange; + if (receivingFocus && selectionRange !is null) return selectionRangeStruct; /* allow the selection change to proceed */ NSRange result = NSRange(); diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/Composite.d --- a/dwt/widgets/Composite.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/Composite.d Tue Dec 30 18:54:31 2008 +0100 @@ -77,6 +77,14 @@ * @see Sample code and further information */ public class Composite : Scrollable { + + alias Scrollable.computeSize computeSize; + alias Scrollable.forceFocus forceFocus; + alias Scrollable.moveAbove moveAbove; + alias Scrollable.moveBelow moveBelow; + alias Scrollable.setBounds setBounds; + alias Scrollable.translateTraversal translateTraversal; + Layout layout_; Control[] tabList; int layoutCount, backgroundMode; diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/CoolBar.d --- a/dwt/widgets/CoolBar.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/CoolBar.d Tue Dec 30 18:54:31 2008 +0100 @@ -59,7 +59,7 @@ */ public class CoolBar : Composite { CoolItem[][] items; - CoolItem[] originalItems = new CoolItem[0]; + CoolItem[] originalItems; Cursor hoverCursor, dragCursor, cursor; CoolItem dragging = null; int mouseXOffset, itemXOffset; @@ -136,6 +136,8 @@ for (int i = 0; i < events.length; i++) { addListener(events[i], listener); } + + originalItems = new CoolItem[0]; } static int checkStyle (int style) { style |= DWT.NO_FOCUS; @@ -259,7 +261,7 @@ Point findItem (CoolItem item) { for (int row = 0; row < items.length; row++) { for (int i = 0; i < items[row].length; i++) { - if (items[row][i].equals(item)) return new Point(i, row); + if (items[row][i].opEquals(item)) return new Point(i, row); } } return new Point(-1, -1); @@ -308,7 +310,7 @@ int answer = 0; for (int row = 0; row < items.length; row++) { for (int i = 0; i < items[row].length; i++) { - if (items[row][i].equals(item)) { + if (items[row][i].opEquals(item)) { return answer; } else { answer++; @@ -386,7 +388,7 @@ int itemCount = getItemCount(), row = 0; if (!(0 <= index && index <= itemCount)) error (DWT.ERROR_INVALID_RANGE); if (items.length is 0) { - items = new CoolItem[1][1]; + items = new CoolItem[][](1, 1); items[0][0] = item; } else { int i = index; @@ -469,8 +471,8 @@ internalRedraw(old.x, old.y, CoolItem.MINIMUM_WIDTH, old.height); if (newRowIndex is items.length) { /* Create a new bottom row for the item. */ - CoolItem[][] newRows = new CoolItem[items.length + 1][]; - System.arraycopy(items, 0, newRows, 0, items.length); + CoolItem[][] newRows = new CoolItem[][](items.length + 1); + SimpleType!(CoolItem[]).arraycopy(items, 0, newRows, 0, items.length); int row = items.length; newRows[row] = new CoolItem[1]; newRows[row][0] = item; @@ -569,8 +571,8 @@ int newRowIndex = Math.max(0, oldRowIndex - 1); if (oldRowIndex is 0) { /* Create a new top row for the item. */ - CoolItem[][] newRows = new CoolItem[items.length + 1][]; - System.arraycopy(items, 0, newRows, 1, items.length); + CoolItem[][] newRows = new CoolItem[][](items.length + 1); + SimpleType!(CoolItem[]).arraycopy(items, 0, newRows, 1, items.length); newRows[0] = new CoolItem[1]; newRows[0][0] = item; items = newRows; @@ -805,9 +807,9 @@ items[rowIndex] = newRow; items[rowIndex][0].wrap = true; } else { - CoolItem[][] newRows = new CoolItem[items.length - 1][]; - System.arraycopy(items, 0, newRows, 0, rowIndex); - System.arraycopy(items, rowIndex + 1, newRows, rowIndex, newRows.length - rowIndex); + CoolItem[][] newRows = new CoolItem[][](items.length - 1); + SimpleType!(CoolItem[]).arraycopy(items, 0, newRows, 0, rowIndex); + SimpleType!(CoolItem[]).arraycopy(items, rowIndex + 1, newRows, rowIndex, newRows.length - rowIndex); items = newRows; return; } @@ -968,7 +970,7 @@ for (int i = 0; i < count; i++) { row[i] = originalItems[itemOrder[i]]; } - items = new CoolItem[1][count]; + items = new CoolItem[][](1, count); items[0] = row; } /** @@ -1164,7 +1166,7 @@ System.arraycopy(items[row], 0, itemsVisual, start, items[row].length); start += items[row].length; } - CoolItem[][] newItems = new CoolItem[itemCount][]; + CoolItem[][] newItems = new CoolItem[][](itemCount); int rowCount = 0, rowWidth = 0; start = 0; for (int i = 0; i < itemCount; i++) { @@ -1195,8 +1197,8 @@ rowCount++; } if (newItems.length !is rowCount) { - CoolItem[][] tmp = new CoolItem[rowCount][]; - System.arraycopy(newItems, 0, tmp, 0, rowCount); + CoolItem[][] tmp = new CoolItem[][](rowCount); + SimpleType!(CoolItem[]).arraycopy(newItems, 0, tmp, 0, rowCount); items = tmp; } else { items = newItems; diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/CoolItem.d --- a/dwt/widgets/CoolItem.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/CoolItem.d Tue Dec 30 18:54:31 2008 +0100 @@ -33,6 +33,7 @@ import dwt.widgets.CoolBar; import dwt.widgets.Event; import dwt.widgets.Item; +import dwt.widgets.Listener; import dwt.widgets.ToolBar; import dwt.widgets.ToolItem; import dwt.widgets.TypedListener; @@ -58,16 +59,16 @@ CoolBar parent; bool ideal; int preferredWidth, preferredHeight, minimumWidth, minimumHeight, requestedWidth; - Rectangle itemBounds = new Rectangle(0, 0, 0, 0); + Rectangle itemBounds; - static final int MARGIN_WIDTH = 4; - static final int GRABBER_WIDTH = 2; - static final int MINIMUM_WIDTH = (2 * MARGIN_WIDTH) + GRABBER_WIDTH; + static const int MARGIN_WIDTH = 4; + static const int GRABBER_WIDTH = 2; + static const int MINIMUM_WIDTH = (2 * MARGIN_WIDTH) + GRABBER_WIDTH; private int CHEVRON_HORIZONTAL_TRIM = -1; //platform dependent values private int CHEVRON_VERTICAL_TRIM = -1; - private static final int CHEVRON_LEFT_MARGIN = 2; - private static final int CHEVRON_IMAGE_WIDTH = 8; //Width to draw the double arrow + private static const int CHEVRON_LEFT_MARGIN = 2; + private static const int CHEVRON_IMAGE_WIDTH = 8; //Width to draw the double arrow ToolBar chevron; bool wrap; @@ -108,6 +109,8 @@ this.parent = parent; parent.createItem (this, parent.getItemCount()); calculateChevronTrim (); + + itemBounds = new Rectangle(0, 0, 0, 0); } /** * Constructs a new instance of this class given its parent @@ -146,6 +149,8 @@ this.parent = parent; parent.createItem (this, index); calculateChevronTrim (); + + itemBounds = new Rectangle(0, 0, 0, 0); } /** * Adds the listener to the collection of listeners that will @@ -637,7 +642,7 @@ ToolItem toolItem = new ToolItem (chevron, DWT.PUSH); toolItem.addListener (DWT.Selection, new class () Listener { public void handleEvent (Event event) { - CoolItem.outer.onSelection (event); + this.outer.onSelection (event); } }); } diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/DateTime.d --- a/dwt/widgets/DateTime.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/DateTime.d Tue Dec 30 18:54:31 2008 +0100 @@ -31,7 +31,7 @@ import tango.text.convert.Format; -import dwt.internal.c.Carbon; +import Carbon = dwt.internal.c.Carbon; import dwt.widgets.Composite; import dwt.widgets.TypedListener; @@ -270,8 +270,8 @@ } String getNameText() { - return (style & DWT.TIME) !is 0 ? Format("{}{}{}{}{}", getHours() , ":" + getMinutes() , ":" , getSeconds()) - : Format("{}{}{}{}{}", (getMonth() + 1) + "/" + getDay() + "/" + getYear()); + return (style & DWT.TIME) !is 0 ? Format("{}{}{}{}{}", getHours() , ":" , getMinutes() , ":" , getSeconds()) + : Format("{}{}{}{}{}", (getMonth() + 1) , "/" , getDay() , "/" , getYear()); } /** @@ -339,7 +339,7 @@ postEvent (DWT.Selection); } -void setBackground (CGFloat [] color) { +void setBackground (Carbon.CGFloat [] color) { NSColor nsColor; if (color is null) { return; // TODO reset to OS default @@ -400,7 +400,7 @@ } } -void setForeground (CGFloat [] color) { +void setForeground (Carbon.CGFloat [] color) { NSColor nsColor; if (color is null) { return; // TODO reset to OS default diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/Display.d --- a/dwt/widgets/Display.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/Display.d Tue Dec 30 18:54:31 2008 +0100 @@ -96,8 +96,6 @@ 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 diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/ExpandBar.d --- a/dwt/widgets/ExpandBar.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/ExpandBar.d Tue Dec 30 18:54:31 2008 +0100 @@ -28,6 +28,8 @@ import dwt.graphics.Rectangle; import dwt.widgets.Composite; +import dwt.widgets.Control; +import dwt.widgets.Display; import dwt.widgets.Event; import dwt.widgets.ExpandItem; import dwt.widgets.Listener; @@ -355,7 +357,7 @@ return -1; } -void layoutItems (int index, bool setScrollbar) { +void layoutItems (int index, bool setScrollbar_) { if (index < itemCount) { int y = spacing - yCurrentScroll; for (int i = 0; i < index; i++) { @@ -370,7 +372,7 @@ y += item.getHeaderHeight() + spacing; } } - if (setScrollbar) setScrollbar (); + if (setScrollbar_) setScrollbar (); } /** diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/FileDialog.d --- a/dwt/widgets/FileDialog.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/FileDialog.d Tue Dec 30 18:54:31 2008 +0100 @@ -49,9 +49,9 @@ * @see Sample code and further information */ public class FileDialog : Dialog { - String [] filterNames = new String [0]; - String [] filterExtensions = new String [0]; - String [] fileNames = new String [0]; + String [] filterNames; + String [] filterExtensions; + String [] fileNames; String filterPath = "", fileName = ""; int filterIndex = -1; bool overwrite = true; //TODO: if setOverwrite(false) is implemented, change default to false for consistency @@ -101,6 +101,10 @@ public this (Shell parent, int style) { super (parent, checkStyle (parent, style)); checkSubclass (); + + filterNames = new String [0]; + filterExtensions = new String [0]; + fileNames = new String [0]; } /** diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/Label.d --- a/dwt/widgets/Label.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/Label.d Tue Dec 30 18:54:31 2008 +0100 @@ -43,7 +43,7 @@ import dwt.internal.cocoa.SWTTextField; import cocoa = dwt.internal.cocoa.id; -import dwt.internal.c.Carbon; +import Carbon = dwt.internal.c.Carbon; import objc = dwt.internal.objc.runtime; import dwt.widgets.Composite; import dwt.widgets.Control; @@ -387,7 +387,7 @@ _setAlignment(); } -void setBackground (CGFloat [] color) { +void setBackground (Carbon.CGFloat [] color) { if ((style & DWT.SEPARATOR) !is 0) return; textView.setDrawsBackground(color !is null); if (color is null) return; @@ -417,7 +417,7 @@ } } -void setForeground (CGFloat [] color) { +void setForeground (Carbon.CGFloat [] color) { if ((style & DWT.SEPARATOR) !is 0) return; NSCell cell = new NSCell(textView.cell()); cell.setAttributedStringValue(createString()); diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/Link.d --- a/dwt/widgets/Link.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/Link.d Tue Dec 30 18:54:31 2008 +0100 @@ -36,8 +36,10 @@ static import tango.text.Text; import objc = dwt.internal.objc.runtime; +import dwt.widgets.Event; import dwt.widgets.Composite; import dwt.widgets.Control; +import dwt.widgets.TypedListener; /** @@ -146,7 +148,7 @@ if (hHint !is DWT.DEFAULT && hHint < 0) hHint = 0; int width, height; //TODO wrapping, wHint - int borderStyle = hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder; + NSBorderType borderStyle = hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder; NSSize borderSize = NSScrollView.frameSizeForContentSize(NSSize(), false, false, borderStyle); NSTextView widget = cast(NSTextView)view; NSSize size = widget.textStorage().size(); @@ -171,7 +173,7 @@ void createHandle () { NSScrollView scrollWidget = cast(NSScrollView)(new SWTScrollView()).alloc(); - scrollWidget.initWithFrame(new NSRect ()); + scrollWidget.initWithFrame(NSRect ()); scrollWidget.setDrawsBackground(false); scrollWidget.setBorderType(hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder); @@ -311,7 +313,7 @@ parseMnemonics (buffer, linkStart, endtagStart, result); offsets [linkIndex] = new Point (offset, result.length () - 1); if (ids [linkIndex] is null) { - ids [linkIndex] = new String (buffer, linkStart, endtagStart - linkStart); + ids [linkIndex] = new_String (buffer, linkStart, endtagStart - linkStart); } linkIndex++; start = tagStart = linkStart = endtagStart = refStart = index + 1; @@ -342,7 +344,7 @@ break; case 12: if (c is '"') { - ids[linkIndex] = new String (buffer, refStart, index - refStart); + ids[linkIndex] = new_String (buffer, refStart, index - refStart); state = 2; } break; diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/List.d --- a/dwt/widgets/List.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/List.d Tue Dec 30 18:54:31 2008 +0100 @@ -44,7 +44,7 @@ import dwt.internal.cocoa.SWTTableView; import cocoa = dwt.internal.cocoa.id; -import dwt.internal.c.Carbon; +import Carbon = dwt.internal.c.Carbon; import dwt.internal.objc.cocoa.Cocoa; import objc = dwt.internal.objc.runtime; import dwt.widgets.Composite; @@ -542,7 +542,7 @@ NSIndexSet selection = widget.selectedRowIndexes(); NSUInteger count = selection.count(); NSUInteger [] indexBuffer = new NSUInteger [count]; - selection.getIndexes(indexBuffer.ptr, count, 0); + selection.getIndexes(indexBuffer.ptr, count, null); String [] result = new String [count]; for (NSUInteger i=0; i 1)) return; - int [] ids = new int [length]; + int length_ = indices.length; + if (length_ is 0 || ((style & DWT.SINGLE) !is 0 && length_ > 1)) return; + int [] ids = new int [length_]; int count = 0; - for (int i=0; i= 0 && index < itemCount) { ids [count++] = index + 1; } @@ -1246,12 +1246,12 @@ checkWidget (); if (items is null) error (DWT.ERROR_NULL_ARGUMENT); deselectAll (); - int length = items.length; - if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return; + int length_ = items.length; + if (length_ is 0 || ((style & DWT.SINGLE) !is 0 && length_ > 1)) return; int count = 0; - int [] ids = new int [length]; - for (int i=0; i 1)) return; - int [] indices = new int [length]; + int length_ = items.length; + if (length_ is 0 || ((style & DWT.SINGLE) !is 0 && length_ > 1)) return; + int [] indices = new int [length_]; int count = 0; - for (int i=0; iSample code and further information */ public class Text : Scrollable { - int textLimit = LIMIT, tabs = 8; + int textLimit, tabs = 8; char echoCharacter; bool doubleClick, receivingFocus; String hiddenText, message; - NSRange selectionRange; + NSRange* selectionRange; + NSRange selectionRangeStruct; /** * The maximum number of characters that can be entered @@ -152,6 +154,8 @@ * @see Widget#getStyle */ public this (Composite parent, int style) { + textLimit = LIMIT; + super (parent, checkStyle (style)); if ((style & DWT.SEARCH) !is 0) { // int inAttributesToSet = (style & DWT.CANCEL) !is 0 ? OS.kHISearchFieldAttributesCancel : 0; @@ -1130,11 +1134,11 @@ String oldText = getText (); if (textLimit !is LIMIT) { int charCount = oldText.length (); - if (charCount - (selection.y - selection.x) + length > textLimit) { + if (charCount - (selection.y - selection.x) + length_ > textLimit) { string = string.substring(0, textLimit - charCount + (selection.y - selection.x)); } } - String newText = oldText.substring (0, selection.x) + string + oldText.substring (selection.y); + String newText = oldText.substring (0, selection.x) ~ string ~ oldText.substring (selection.y); setEditText (newText); setSelection (selection.x + string.length ()); } @@ -1349,7 +1353,7 @@ break; default: if (character !is '\t' && character < 0x20) return true; - oldText = new String ([character]); + oldText = new_String ([character]); } String newText = verifyText (oldText, start, end, nsEvent); if (newText is null) return false; @@ -1371,7 +1375,7 @@ return result; } -void setBackground (CGFloat [] color) { +void setBackground (Carbon.CGFloat [] color) { NSColor nsColor; if (color is null) { return; // TODO reset to OS default @@ -1494,7 +1498,7 @@ super.setFont (font); } -void setForeground (CGFloat [] color) { +void setForeground (Carbon.CGFloat [] color) { NSColor nsColor; if (color is null) { return; // TODO reset to OS default @@ -1625,12 +1629,13 @@ int length = cast(int)/*64*/str.length (); int selStart = Math.min (Math.max (Math.min (start, end), 0), length); int selEnd = Math.min (Math.max (Math.max (start, end), 0), length); - selectionRange = NSRange (); + selectionRangeStruct = NSRange (); + selectionRange = &selectionRangeStruct; selectionRange.location = selStart; selectionRange.length = selEnd - selStart; if (this is display.getFocusControl ()) { NSText editor = view.window ().fieldEditor (false, view); - editor.setSelectedRange (selectionRange); + editor.setSelectedRange (selectionRangeStruct); } } else { int length = cast(int)/*64*/(cast(NSTextView) view).textStorage ().length (); @@ -1816,7 +1821,8 @@ void textViewDidChangeSelection(objc.id id, objc.SEL sel, objc.id aNotification) { NSNotification notification = new NSNotification (aNotification); NSText editor = new NSText (notification.object ().id); - selectionRange = editor.selectedRange (); + selectionRangeStruct = editor.selectedRange (); + selectionRange = &selectionRangeStruct; } void textDidChange (objc.id id, objc.SEL sel, objc.id aNotification) { @@ -1829,7 +1835,7 @@ * then return the receiver's last selection range, otherwise the full * text will be automatically selected. */ - if (receivingFocus && selectionRange !is null) return selectionRange; + if (receivingFocus && selectionRange !is null) return selectionRangeStruct; /* allow the selection change to proceed */ NSRange result = NSRange (); diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/ToolBar.d --- a/dwt/widgets/ToolBar.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/ToolBar.d Tue Dec 30 18:54:31 2008 +0100 @@ -66,6 +66,13 @@ * @see Sample code and further information */ public class ToolBar : Composite { + + alias Composite.computeSize computeSize; + alias Composite.createHandle createHandle; + alias Composite.forceFocus forceFocus; + alias Composite.setBounds setBounds; + alias Composite.setToolTipText setToolTipText; + int itemCount; ToolItem [] items; NSArray accessibilityAttributes = null; diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/Tracker.d --- a/dwt/widgets/Tracker.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/Tracker.d Tue Dec 30 18:54:31 2008 +0100 @@ -37,7 +37,7 @@ import dwt.internal.cocoa.NSWindow; import dwt.internal.cocoa.OS; -import dwt.internal.c.Carbon; +import Carbon = dwt.internal.c.Carbon; import dwt.internal.objc.cocoa.Cocoa; import dwt.widgets.Composite; import dwt.widgets.Control; @@ -86,12 +86,6 @@ const static int STEPSIZE_SMALL = 1; const static int STEPSIZE_LARGE = 9; - static this () - { - rectangles = new Rectangle [0]; - proportions = rectangles; - } - /** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. @@ -125,6 +119,9 @@ * @see Widget#getStyle */ public this (Composite parent, int style) { + rectangles = new Rectangle [0]; + proportions = rectangles; + super (parent, checkStyle (style)); this.parent = parent; } @@ -164,6 +161,9 @@ * @see DWT#DOWN */ public this (Display display, int style) { + rectangles = new Rectangle [0]; + proportions = rectangles; + if (display is null) display = Display.getCurrent (); if (display is null) display = Display.getDefault (); if (!display.isValidThread ()) { @@ -742,14 +742,14 @@ tracking = true; window = cast(NSWindow)(new NSWindow()).alloc(); NSArray screens = NSScreen.screens(); - CGFloat minX = Float.MAX_VALUE, maxX = Float.MIN_VALUE; - CGFloat minY = Float.MAX_VALUE, maxY = Float.MIN_VALUE; + Carbon.CGFloat minX = Float.MAX_VALUE, maxX = Float.MIN_VALUE; + Carbon.CGFloat minY = Float.MAX_VALUE, maxY = Float.MIN_VALUE; int count = cast(int)/*64*/screens.count(); for (int i = 0; i < count; i++) { NSScreen screen = new NSScreen(screens.objectAtIndex(i)); NSRect frame = screen.frame(); - CGFloat x1 = frame.x, x2 = frame.x + frame.width; - CGFloat y1 = frame.y, y2 = frame.y + frame.height; + Carbon.CGFloat x1 = frame.x, x2 = frame.x + frame.width; + Carbon.CGFloat y1 = frame.y, y2 = frame.y + frame.height; if (x1 < minX) minX = x1; if (x2 < minX) minX = x2; if (x1 > maxX) maxX = x1; diff -r 8e3c85e1733d -r c7f7f4d7091a dwt/widgets/Tree.d --- a/dwt/widgets/Tree.d Tue Dec 30 17:01:10 2008 +0100 +++ b/dwt/widgets/Tree.d Tue Dec 30 18:54:31 2008 +0100 @@ -63,7 +63,7 @@ import dwt.internal.cocoa.SWTTreeItem; import cocoa = dwt.internal.cocoa.id; -import dwt.internal.c.Carbon; +import Carbon = dwt.internal.c.Carbon; import dwt.internal.objc.cocoa.Cocoa; import objc = dwt.internal.objc.runtime; import dwt.widgets.Composite; @@ -139,7 +139,7 @@ TreeColumn sortColumn; int columnCount; int sortDirection; - CGFloat levelIndent; + Carbon.CGFloat levelIndent; bool ignoreExpand, ignoreSelect; /** @@ -423,7 +423,7 @@ // GC gc = new GC (this); // width = calculateWidth (childIds, gc, true, 0, levelIndent); // gc.dispose (); -// width += getInsetWidth (column_id, true); +// width += getInsetWidth (columnid, true); } if ((style & DWT.CHECK) !is 0) width += getCheckColumnWidth (); } else { @@ -930,11 +930,11 @@ GC gc = GC.cocoa_new (this, data); gc.setFont (item.getFont (columnIndex)); if (isSelected) { - CGFloat[] components = new CGFloat[nsSelectionForeground.numberOfComponents ()]; + Carbon.CGFloat[] components = new Carbon.CGFloat[nsSelectionForeground.numberOfComponents ()]; nsSelectionForeground.getComponents (components.ptr); Color selectionForeground = Color.cocoa_new (display, components); gc.setForeground (selectionForeground); - components = new CGFloat[nsSelectionBackground.numberOfComponents ()]; + components = new Carbon.CGFloat[nsSelectionBackground.numberOfComponents ()]; nsSelectionBackground.getComponents (components.ptr); Color selectionBackground = Color.cocoa_new (display, components); gc.setBackground (selectionBackground); @@ -974,7 +974,7 @@ NSRect rowRect = outlineView.rectOfRow (rowIndex); if ((style & DWT.CHECK) !is 0) { /* highlighting at this stage draws over the checkbox, so don't include its column */ - CGFloat checkWidth = checkColumn.width (); + Carbon.CGFloat checkWidth = checkColumn.width (); selectionRect.x = checkWidth; selectionRect.width = rowRect.width - checkWidth; } else { @@ -988,7 +988,7 @@ if (drawBackground && !drawSelection) { NSGraphicsContext context = NSGraphicsContext.currentContext (); context.saveGraphicsState (); - CGFloat[] colorRGB = background.handle; + Carbon.CGFloat[] colorRGB = background.handle; NSColor color = NSColor.colorWithDeviceRed (colorRGB[0], colorRGB[1], colorRGB[2], 1f); color.setFill (); NSBezierPath.fillRect (fullRect); @@ -1021,11 +1021,11 @@ GC gc = GC.cocoa_new (this, data); gc.setFont (item.getFont (columnIndex)); if (isSelected) { - CGFloat[] components = new CGFloat[nsSelectionForeground.numberOfComponents ()]; + Carbon.CGFloat[] components = new Carbon.CGFloat[nsSelectionForeground.numberOfComponents ()]; nsSelectionForeground.getComponents (components.ptr); Color selectionForeground = Color.cocoa_new (display, components); gc.setForeground (selectionForeground); - components = new CGFloat[nsSelectionBackground.numberOfComponents ()]; + components = new Carbon.CGFloat[nsSelectionBackground.numberOfComponents ()]; nsSelectionBackground.getComponents (components.ptr); Color selectionBackground = Color.cocoa_new (display, components); gc.setBackground (selectionBackground); @@ -1560,7 +1560,7 @@ // for (int i=0; i