Mercurial > projects > dwt-mac
diff dwt/widgets/Table.d @ 123:63a09873578e
Fixed compile errors
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Thu, 15 Jan 2009 23:08:54 +0100 |
parents | c7f7f4d7091a |
children | ad4e1fe71a5a |
line wrap: on
line diff
--- a/dwt/widgets/Table.d Wed Dec 31 21:01:13 2008 +0100 +++ b/dwt/widgets/Table.d Thu Jan 15 23:08:54 2009 +0100 @@ -119,6 +119,10 @@ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> */ public class Table : Composite { + + alias Composite.setBackground setBackground; + alias Composite.setFont setFont; + TableItem [] items; TableColumn [] columns; TableColumn sortColumn; @@ -128,7 +132,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. @@ -240,7 +244,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; @@ -248,14 +252,14 @@ static int checkStyle (int style) { /* - * Feature in Windows. Even when WS_HSCROLL or - * WS_VSCROLL is not specified, Windows creates - * trees and tables with scroll bars. The fix - * is to set H_SCROLL and V_SCROLL. - * - * NOTE: This code appears on all platforms so that - * applications have consistent scroll bar behavior. - */ + * Feature in Windows. Even when WS_HSCROLL or + * WS_VSCROLL is not specified, Windows creates + * trees and tables with scroll bars. The fix + * is to set H_SCROLL and V_SCROLL. + * + * NOTE: This code appears on all platforms so that + * applications have consistent scroll bar behavior. + */ if ((style & DWT.NO_SCROLL) is 0) { style |= DWT.H_SCROLL | DWT.V_SCROLL; } @@ -455,10 +459,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(); @@ -475,7 +479,7 @@ checkColumn.setResizingMask(OS.NSTableColumnNoResizing); checkColumn.setEditable(false); } - + firstColumn = cast(NSTableColumn)(new NSTableColumn()).alloc(); firstColumn.initWithIdentifier(firstColumn); firstColumn.setMinWidth(0); @@ -483,7 +487,7 @@ dataCell = cast(NSBrowserCell)(new SWTBrowserCell ()).alloc ().init (); firstColumn.setDataCell (dataCell); widget.addTableColumn (firstColumn); - + scrollView = scrollWidget; view = widget; } @@ -765,9 +769,9 @@ } } } - + NSInteger oldIndex = (cast(NSTableView)view).columnWithIdentifier (column.nsColumn); - + if (columnCount is 1) { //TODO - reset attributes firstColumn = column.nsColumn; @@ -777,7 +781,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++) { @@ -804,14 +808,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); @@ -831,14 +835,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) { @@ -851,7 +855,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) { @@ -865,7 +869,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 @@ -896,7 +900,7 @@ gc.setForeground (item.getForeground (columnIndex)); gc.setBackground (item.getBackground (columnIndex)); } - + Event event = new Event (); event.item = item; event.gc = gc; @@ -918,7 +922,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; @@ -939,7 +943,7 @@ callSuper (tableView.id, OS.sel_highlightSelectionInClipRect_, selectionRect); } } - + if (drawBackground && !drawSelection) { NSGraphicsContext context = NSGraphicsContext.currentContext (); context.saveGraphicsState (); @@ -949,16 +953,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. @@ -989,7 +993,7 @@ gc.setForeground (item.getForeground (columnIndex)); gc.setBackground (item.getBackground (columnIndex)); } - + Event event = new Event (); event.item = item; event.gc = gc; @@ -1701,7 +1705,7 @@ if (itemCount is 0) { setTableEmpty (); } else { -// fixScrollBar (); + // fixScrollBar (); } } @@ -2121,7 +2125,7 @@ if (itemHeight is -1) { //TODO - reset item height, ensure other API's such as setFont don't do this } else { -// OS.SetDataBrowserTableViewRowHeight (handle, cast(short) itemHeight); + // OS.SetDataBrowserTableViewRowHeight (handle, cast(short) itemHeight); } } @@ -2165,7 +2169,7 @@ bool setScrollWidth (TableItem items[], bool callMeasureItem) { if (columnCount !is 0) return false; if (currentItem !is null) { -// if (currentItem !is item) fixScrollWidth = true; + // if (currentItem !is item) fixScrollWidth = true; return false; } if (/*ignoreRedraw ||*/ drawCount !is 0) return false; @@ -2216,7 +2220,7 @@ } void setSelection (int index, bool notify) { -// checkWidget (); + // checkWidget (); if (0 <= index && index < itemCount) { select (index); showIndex (index); @@ -2578,14 +2582,14 @@ cocoa.id columnId = userInfo.valueForKey (NSString.stringWith ("NSTableColumn")); //$NON-NLS-1$ TableColumn column = getColumn (columnId); if (column is null) return; /* either CHECK column or firstColumn in 0-column Table */ - + column.sendEvent (DWT.Resize); if (isDisposed ()) return; - + NSTableView tableView = cast(NSTableView)view; int index = cast(int)/*64*/tableView.columnWithIdentifier (columnId); if (index is -1) return; /* column was disposed in Resize callback */ - + NSArray nsColumns = tableView.tableColumns (); int columnCount = cast(int)/*64*/tableView.numberOfColumns (); for (int i = index + 1; i < columnCount; i++) { @@ -2671,14 +2675,14 @@ cell.setFont (item.getFont (columnIndex).handle); cell.setImage (image !is null ? image.handle : null); cell.setLeaf (true); - + if (hooks (DWT.MeasureItem)) { NSTableView tableView = cast(NSTableView)this.view; NSInteger nsColumnIndex = tableView.columnWithIdentifier (new cocoa.id (aTableColumn)); NSRect rect = tableView.frameOfCellAtColumn (nsColumnIndex, cast(NSInteger) rowIndex); NSRect contentRect = cell.titleRectForBounds (rect); NSSize contentSize = cell.cellSizeForBounds (rect); - + GCData data = new GCData (); data.paintRectStruct = tableView.frame (); data.paintRect = &data.paintRectStruct;