# HG changeset patch # User Jacob Carlborg # Date 1234296084 -3600 # Node ID 3d4579727e0e7f4c89fb3302c02e19d00548e287 # Parent ad4e1fe71a5a41d988d14be78265911c8572c5f4 Fixes #2 and #3 diff -r ad4e1fe71a5a -r 3d4579727e0e dwt/custom/CCombo.d --- a/dwt/custom/CCombo.d Sun Jan 18 18:39:46 2009 +0100 +++ b/dwt/custom/CCombo.d Tue Feb 10 21:01:24 2009 +0100 @@ -134,26 +134,40 @@ if ((style & DWT.FLAT) !is 0) arrowStyle |= DWT.FLAT; arrow = new Button (this, arrowStyle); - listener = new class() Listener { + listener = new class(text, list, popup, arrow) Listener { + + Text text; + List list; + Shell popup; + Button arrow; + + this (Text text, List list, Shell popup, Button arrow) + { + this.text = text; + this.list = list; + this.popup = popup; + this.arrow = arrow; + } + public void handleEvent (Event event) { if (popup is event.widget) { - popupEvent (event); + this.outer.popupEvent (event); return; } if (text is event.widget) { - textEvent (event); + this.outer.textEvent (event); return; } if (list is event.widget) { - listEvent (event); + this.outer.listEvent (event); return; } if (arrow is event.widget) { - arrowEvent (event); + this.outer.arrowEvent (event); return; } if (this.outer is event.widget) { - comboEvent (event); + this.outer.comboEvent (event); return; } if (getShell () is event.widget) { diff -r ad4e1fe71a5a -r 3d4579727e0e dwt/custom/PopupList.d --- a/dwt/custom/PopupList.d Sun Jan 18 18:39:46 2009 +0100 +++ b/dwt/custom/PopupList.d Tue Feb 10 21:01:24 2009 +0100 @@ -32,6 +32,8 @@ import dwt.widgets.Listener; import dwt.widgets.Shell; +import tango.text.Util; + /** * A PopupList is a list of selectable items that appears in its own shell positioned above * its parent shell. It is used for selecting items when editing a Table cell (similar to the diff -r ad4e1fe71a5a -r 3d4579727e0e dwt/dwthelper/array.d --- a/dwt/dwthelper/array.d Sun Jan 18 18:39:46 2009 +0100 +++ b/dwt/dwthelper/array.d Tue Feb 10 21:01:24 2009 +0100 @@ -205,10 +205,6 @@ { assert(start >= 0); } -out (result) -{ - assert(result >= -1 && result < arr.length); -} body { size_t index = tango.text.Util.locatePattern(arr, match, start); @@ -239,10 +235,6 @@ { assert(start >= 0); } -out (result) -{ - assert(result >= -1 && result < arr.length); -} body { size_t index; diff -r ad4e1fe71a5a -r 3d4579727e0e dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Sun Jan 18 18:39:46 2009 +0100 +++ b/dwt/dwthelper/utils.d Tue Feb 10 21:01:24 2009 +0100 @@ -26,6 +26,7 @@ static import tango.text.Util; static import tango.text.Text; import tango.text.Unicode; +public import Utf = tango.text.convert.Utf; import tango.text.convert.Utf; import tango.core.Exception; import tango.stdc.stdlib : exit; diff -r ad4e1fe71a5a -r 3d4579727e0e dwt/internal/Compatibility.d --- a/dwt/internal/Compatibility.d Sun Jan 18 18:39:46 2009 +0100 +++ b/dwt/internal/Compatibility.d Tue Feb 10 21:01:24 2009 +0100 @@ -296,7 +296,7 @@ proc.execute; } -const ImportData[] SWTMessagesBundleData = [ +const ImportData[] SWTMessagesBundleData = [/* getImportData!( "swt.internal.SWTMessages.properties" ), getImportData!( "swt.internal.SWTMessages_ar.properties" ), getImportData!( "swt.internal.SWTMessages_cs.properties" ), @@ -322,7 +322,7 @@ getImportData!( "swt.internal.SWTMessages_zh_HK.properties" ), getImportData!( "swt.internal.SWTMessages_zh.properties" ), getImportData!( "swt.internal.SWTMessages_zh_TW.properties" ) -]; +*/]; private static ResourceBundle msgs = null; diff -r ad4e1fe71a5a -r 3d4579727e0e dwt/internal/cocoa/OS.d --- a/dwt/internal/cocoa/OS.d Sun Jan 18 18:39:46 2009 +0100 +++ b/dwt/internal/cocoa/OS.d Tue Feb 10 21:01:24 2009 +0100 @@ -32,11 +32,14 @@ NSGrooveBorder = 3 } + + import dwt.dwthelper.utils; import dwt.internal.C; import dwt.internal.Library; +import tango.core.Memory; import unistd = tango.stdc.posix.unistd; import stdc = tango.stdc.string; @@ -1361,13 +1364,19 @@ /** @method flags=jni */ public static void* NewGlobalRef (Object object) { - return cast(void*) object; + auto o = cast(void*) object; + GC.addRoot(o); + + return o; } /** * @method flags=jni * @param globalRef cast=(jobject) */ -//public static final void DeleteGlobalRef(void* globalRef){} +public static void DeleteGlobalRef(void* globalRef) +{ + GC.removeRoot(globalRef); +} /** @method flags=no_gen */ public static Object JNIGetObject (void* globalRef) { diff -r ad4e1fe71a5a -r 3d4579727e0e dwt/printing/Printer.d --- a/dwt/printing/Printer.d Sun Jan 18 18:39:46 2009 +0100 +++ b/dwt/printing/Printer.d Tue Feb 10 21:01:24 2009 +0100 @@ -42,6 +42,7 @@ import Carbon = dwt.internal.c.Carbon; import dwt.internal.objc.cocoa.Cocoa; +import objc = dwt.internal.objc.runtime; import dwt.printing.PrinterData; /** diff -r ad4e1fe71a5a -r 3d4579727e0e dwt/widgets/TabItem.d --- a/dwt/widgets/TabItem.d Sun Jan 18 18:39:46 2009 +0100 +++ b/dwt/widgets/TabItem.d Tue Feb 10 21:01:24 2009 +0100 @@ -30,6 +30,7 @@ import dwt.internal.cocoa.NSWindow; import dwt.internal.cocoa.OS; +import objc = dwt.internal.objc.runtime; import dwt.widgets.Control; import dwt.widgets.Item; import dwt.widgets.TabFolder; diff -r ad4e1fe71a5a -r 3d4579727e0e dwt/widgets/Table.d --- a/dwt/widgets/Table.d Sun Jan 18 18:39:46 2009 +0100 +++ b/dwt/widgets/Table.d Tue Feb 10 21:01:24 2009 +0100 @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -137,7 +137,7 @@ NSBrowserCell dataCell; int columnCount, itemCount, lastIndexOf, sortDirection; bool ignoreSelect; - + /** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. @@ -249,7 +249,7 @@ currentItem = null; if (isDisposed () || item.isDisposed ()) return false; if (redraw) { - // if (!setScrollWidth (item)) item.redraw (OS.kDataBrowserNoItem); +// if (!setScrollWidth (item)) item.redraw (OS.kDataBrowserNoItem); } } return true; @@ -464,10 +464,10 @@ widget.setDelegate(widget); widget.setDoubleAction(OS.sel_sendDoubleSelection); if (!hasBorder()) widget.setFocusRingType(OS.NSFocusRingTypeNone); - + headerView = cast(NSTableHeaderView)(new SWTTableHeaderView ()).alloc ().init (); widget.setHeaderView (null); - + NSString str = NSString.stringWith(""); if ((style & DWT.CHECK) !is 0) { checkColumn = cast(NSTableColumn)(new NSTableColumn()).alloc(); @@ -484,7 +484,7 @@ checkColumn.setResizingMask(OS.NSTableColumnNoResizing); checkColumn.setEditable(false); } - + firstColumn = cast(NSTableColumn)(new NSTableColumn()).alloc(); firstColumn.initWithIdentifier(firstColumn); firstColumn.setMinWidth(0); @@ -492,7 +492,7 @@ dataCell = cast(NSBrowserCell)(new SWTBrowserCell ()).alloc ().init (); firstColumn.setDataCell (dataCell); widget.addTableColumn (firstColumn); - + scrollView = scrollWidget; view = widget; } @@ -515,6 +515,7 @@ nsColumn = cast(NSTableColumn)(new NSTableColumn()).alloc(); nsColumn.initWithIdentifier(nsColumn); nsColumn.setMinWidth(0); + (cast(NSTableView)view).addTableColumn (nsColumn); int checkColumn = (style & DWT.CHECK) !is 0 ? 1 : 0; (cast(NSTableView)view).moveColumn (columnCount + checkColumn, index + checkColumn); nsColumn.setDataCell (dataCell); @@ -774,9 +775,9 @@ } } } - + NSInteger oldIndex = (cast(NSTableView)view).columnWithIdentifier (column.nsColumn); - + if (columnCount is 1) { //TODO - reset attributes firstColumn = column.nsColumn; @@ -786,7 +787,7 @@ } System.arraycopy (columns, index + 1, columns, index, --columnCount - index); columns [columnCount] = null; - + NSArray array = (cast(NSTableView)view).tableColumns (); NSUInteger arraySize = array.count (); for (NSUInteger i = oldIndex; i < arraySize; i++) { @@ -813,14 +814,14 @@ if (itemCount is 0) { setTableEmpty (); } else { - // fixScrollBar (); +// fixScrollBar (); } } void drawInteriorWithFrame_inView (objc.id id, objc.SEL sel, objc.id cellFrame, objc.id view) { NSRect rect = NSRect (); OS.memmove (&rect, cellFrame, NSRect.sizeof); - + NSTableView tableView = cast(NSTableView)this.view; NSBrowserCell cell = new NSBrowserCell (id); NSRange rowsRange = tableView.rowsInRect (rect); @@ -840,14 +841,14 @@ } } } - + Color background = item.cellBackground !is null ? item.cellBackground [columnIndex] : null; if (background is null) background = item.background; bool drawBackground = background !is null; bool drawForeground = true; bool isSelected = tableView.isRowSelected (rowIndex); bool drawSelection = isSelected; - + NSColor nsSelectionBackground = null; NSColor nsSelectionForeground = null; if (isSelected) { @@ -860,7 +861,7 @@ nsSelectionBackground = cell.highlightColorInView (tableView); nsSelectionBackground = nsSelectionBackground.colorUsingColorSpace (NSColorSpace.deviceRGBColorSpace ()); } - + NSRect fullRect = NSRect (); fullRect.x = rect.x; fullRect.y = rect.y; fullRect.height = rect.height; if (columnCount is 0) { @@ -874,7 +875,7 @@ NSSize spacing = tableView.intercellSpacing (); fullRect.width = rect.width + spacing.width; } - + if (hooks (DWT.EraseItem)) { NSRect eraseItemRect; // TODO how to handle rearranged columns? The third clause below ensures that @@ -927,7 +928,7 @@ drawForeground = (event.detail & DWT.FOREGROUND) !is 0; drawSelection = drawSelection && (event.detail & DWT.SELECTED) !is 0; } - + if (drawSelection) { NSRect selectionRect = NSRect (); selectionRect.y = rect.y; selectionRect.height = rect.height; @@ -948,7 +949,7 @@ callSuper (tableView.id, OS.sel_highlightSelectionInClipRect_, selectionRect); } } - + if (drawBackground && !drawSelection) { NSGraphicsContext context = NSGraphicsContext.currentContext (); context.saveGraphicsState (); @@ -958,16 +959,16 @@ NSBezierPath.fillRect (fullRect); context.restoreGraphicsState (); } - + if (drawForeground) { cell.setHighlighted (false); callSuper (id, sel, rect, view); } - + if (hooks (DWT.PaintItem)) { NSRect contentRect = cell.titleRectForBounds (rect); NSSize contentSize = cell.cellSizeForBounds (rect); - + GCData data = new GCData (); // TODO how to handle rearranged columns? The third clause below ensures that // there are either 0 columns or that column 0 is still the first physical column. @@ -998,7 +999,7 @@ gc.setForeground (item.getForeground (columnIndex)); gc.setBackground (item.getBackground (columnIndex)); } - + Event event = new Event (); event.item = item; event.gc = gc; @@ -1398,7 +1399,7 @@ selection.getIndexes(indexBuffer.ptr, count, null); TableItem [] result = new TableItem [count]; for (NSUInteger i=0; i