Mercurial > projects > dwt-mac
diff dwt/widgets/Tree.d @ 123:63a09873578e
Fixed compile errors
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Thu, 15 Jan 2009 23:08:54 +0100 |
parents | c7f7f4d7091a |
children | 1a0129cab08e |
line wrap: on
line diff
--- a/dwt/widgets/Tree.d Wed Dec 31 21:01:13 2008 +0100 +++ b/dwt/widgets/Tree.d Thu Jan 15 23:08:54 2009 +0100 @@ -141,7 +141,7 @@ int sortDirection; Carbon.CGFloat levelIndent; bool ignoreExpand, ignoreSelect; - + /** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. @@ -287,13 +287,13 @@ TreeItem parentItem = item.getParentItem (); event.item = item; event.index = parentItem is null ? indexOf (item) : parentItem.indexOf (item); -// ignoreRedraw = true; + // ignoreRedraw = true; sendEvent (DWT.SetData, event); //widget could be disposed at this point -// ignoreRedraw = false; + // ignoreRedraw = false; if (isDisposed () || item.isDisposed ()) return false; if (redraw) { -// if (!setScrollWidth (item)) item.redraw (OS.kDataBrowserNoItem); + // if (!setScrollWidth (item)) item.redraw (OS.kDataBrowserNoItem); } } return true; @@ -301,14 +301,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; } @@ -414,16 +414,16 @@ width += columns [i].getWidth (); } } else { -// int levelIndent = DISCLOSURE_COLUMN_LEVEL_INDENT; -// if (OS.VERSION >= 0x1040) { -// float [] metric = new float [1]; -// OS.DataBrowserGetMetric (handle, OS.kDataBrowserMetricDisclosureColumnPerDepthGap, null, metric); -// levelIndent = cast(int) metric [0]; -// } -// GC gc = new GC (this); -// width = calculateWidth (childIds, gc, true, 0, levelIndent); -// gc.dispose (); -// width += getInsetWidth (columnid, true); + // int levelIndent = DISCLOSURE_COLUMN_LEVEL_INDENT; + // if (OS.VERSION >= 0x1040) { + // float [] metric = new float [1]; + // OS.DataBrowserGetMetric (handle, OS.kDataBrowserMetricDisclosureColumnPerDepthGap, null, metric); + // levelIndent = cast(int) metric [0]; + // } + // GC gc = new GC (this); + // width = calculateWidth (childIds, gc, true, 0, levelIndent); + // gc.dispose (); + // width += getInsetWidth (columnid, true); } if ((style & DWT.CHECK) !is 0) width += getCheckColumnWidth (); } else { @@ -692,27 +692,27 @@ checkWidget (); if (item is null) error (DWT.ERROR_NULL_ARGUMENT); if (item.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT); -// ignoreSelect = true; -// /* -// * Bug in the Macintosh. When the DataBroswer selection flags includes -// * both kDataBrowserNeverEmptySelectionSet and kDataBrowserSelectOnlyOne, -// * two items are selected when SetDataBrowserSelectedItems() is called -// * with kDataBrowserItemsAssign to assign a new seletion despite the fact -// * that kDataBrowserSelectOnlyOne was specified. The fix is to save and -// * restore kDataBrowserNeverEmptySelectionSet around each call to -// * SetDataBrowserSelectedItems(). -// */ -// int [] selectionFlags = null; -// if ((style & DWT.SINGLE) !is 0) { -// selectionFlags = new int [1]; -// OS.GetDataBrowserSelectionFlags (handle, selectionFlags); -// OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0] & ~OS.kDataBrowserNeverEmptySelectionSet); -// } -// OS.SetDataBrowserSelectedItems (handle, 1, new int [] {item.id}, OS.kDataBrowserItemsRemove); -// if ((style & DWT.SINGLE) !is 0) { -// OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0]); -// } -// ignoreSelect = false; + // ignoreSelect = true; + // /* + // * Bug in the Macintosh. When the DataBroswer selection flags includes + // * both kDataBrowserNeverEmptySelectionSet and kDataBrowserSelectOnlyOne, + // * two items are selected when SetDataBrowserSelectedItems() is called + // * with kDataBrowserItemsAssign to assign a new seletion despite the fact + // * that kDataBrowserSelectOnlyOne was specified. The fix is to save and + // * restore kDataBrowserNeverEmptySelectionSet around each call to + // * SetDataBrowserSelectedItems(). + // */ + // int [] selectionFlags = null; + // if ((style & DWT.SINGLE) !is 0) { + // selectionFlags = new int [1]; + // OS.GetDataBrowserSelectionFlags (handle, selectionFlags); + // OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0] & ~OS.kDataBrowserNeverEmptySelectionSet); + // } + // OS.SetDataBrowserSelectedItems (handle, 1, new int [] {item.id}, OS.kDataBrowserItemsRemove); + // if ((style & DWT.SINGLE) !is 0) { + // OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0]); + // } + // ignoreSelect = false; } @@ -778,9 +778,9 @@ } } } - + NSInteger oldIndex = (cast(NSOutlineView)view).columnWithIdentifier (column.nsColumn); - + if (columnCount is 1) { //TODO - reset attributes firstColumn = column.nsColumn; @@ -793,7 +793,7 @@ } System.arraycopy (columns, index + 1, columns, index, --columnCount - index); columns [columnCount] = null; - + NSArray array = (cast(NSOutlineView)view).tableColumns (); NSUInteger arraySize = cast(int)/*64*/array.count (); for (NSUInteger i = oldIndex; i < arraySize; i++) { @@ -823,7 +823,7 @@ if (items [index] is item) break; index++; } -// if (index !is itemCount - 1) fixSelection (index, false); + // if (index !is itemCount - 1) fixSelection (index, false); System.arraycopy (items, index + 1, items, index, --count - index); items [count] = null; if (parentItem !is null) { @@ -842,14 +842,14 @@ //(cast(NSTableView)view).noteNumberOfRowsChanged(); -// setScrollWidth (true); -// fixScrollBar (); + // setScrollWidth (true); + // 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); - + NSOutlineView outlineView = cast(NSOutlineView)this.view; NSBrowserCell cell = new NSBrowserCell (id); NSRange rowsRange = outlineView.rowsInRect (rect); @@ -870,14 +870,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 = outlineView.isRowSelected (rowIndex); bool drawSelection = isSelected; - + NSColor nsSelectionBackground = null; NSColor nsSelectionForeground = null; if (isSelected) { @@ -890,7 +890,7 @@ nsSelectionBackground = cell.highlightColorInView (outlineView); nsSelectionBackground = nsSelectionBackground.colorUsingColorSpace (NSColorSpace.deviceRGBColorSpace ()); } - + NSRect fullRect = NSRect (); fullRect.y = rect.y; fullRect.height = rect.height; if (columnCount is 0) { @@ -911,7 +911,7 @@ fullRect.width = rect.width + spacing.width; } } - + if (hooks (DWT.EraseItem)) { NSRect eraseItemRect; // TODO how to handle rearranged columns? The third clause below ensures that @@ -942,7 +942,7 @@ gc.setForeground (item.getForeground (columnIndex)); gc.setBackground (item.getBackground (columnIndex)); } - + Event event = new Event (); event.item = item; event.gc = gc; @@ -984,7 +984,7 @@ callSuper (outlineView.id, OS.sel_highlightSelectionInClipRect_, selectionRect); } } - + if (drawBackground && !drawSelection) { NSGraphicsContext context = NSGraphicsContext.currentContext (); context.saveGraphicsState (); @@ -994,16 +994,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. @@ -1034,7 +1034,7 @@ gc.setForeground (item.getForeground (columnIndex)); gc.setBackground (item.getBackground (columnIndex)); } - + Event event = new Event (); event.item = item; event.gc = gc; @@ -1051,17 +1051,17 @@ void fixScrollBar () { /* - * Bug in the Macintosh. For some reason, the data browser does not update - * the vertical scrollbar when it is scrolled to the bottom and items are - * removed. The fix is to check if the scrollbar value is bigger the - * maximum number of visible items and clamp it when needed. - */ -// int [] top = new int [1], left = new int [1]; -// OS.GetDataBrowserScrollPosition (handle, top, left); -// int maximum = Math.max (0, getItemHeight () * visibleCount - getClientArea ().height); -// if (top [0] > maximum) { -// OS.SetDataBrowserScrollPosition (handle, maximum, left [0]); -// } + * Bug in the Macintosh. For some reason, the data browser does not update + * the vertical scrollbar when it is scrolled to the bottom and items are + * removed. The fix is to check if the scrollbar value is bigger the + * maximum number of visible items and clamp it when needed. + */ + // int [] top = new int [1], left = new int [1]; + // OS.GetDataBrowserScrollPosition (handle, top, left); + // int maximum = Math.max (0, getItemHeight () * visibleCount - getClientArea ().height); + // if (top [0] > maximum) { + // OS.SetDataBrowserScrollPosition (handle, maximum, left [0]); + // } } int getCheckColumnWidth () { @@ -1554,18 +1554,18 @@ */ public TreeItem getTopItem () { checkWidget (); -// //TODO - optimize -// Rect rect = new Rect (); -// int y = getBorder () + getHeaderHeight (); -// for (int i=0; i<items.length; i++) { -// TreeItem item = items [i]; -// if (item !is null) { -// int columnId = (columnCount is 0) ? columnid : columns [0].id; -// if (OS.GetDataBrowserItemPartBounds (handle, item.id, columnId, OS.kDataBrowserPropertyEnclosingPart, rect) is OS.noErr) { -// if (rect.top <= y && y <= rect.bottom) return item; -// } -// } -// } + // //TODO - optimize + // Rect rect = new Rect (); + // int y = getBorder () + getHeaderHeight (); + // for (int i=0; i<items.length; i++) { + // TreeItem item = items [i]; + // if (item !is null) { + // int columnId = (columnCount is 0) ? columnid : columns [0].id; + // if (OS.GetDataBrowserItemPartBounds (handle, item.id, columnId, OS.kDataBrowserPropertyEnclosingPart, rect) is OS.noErr) { + // if (rect.top <= y && y <= rect.bottom) return item; + // } + // } + // } return null; } @@ -1697,7 +1697,7 @@ NSBrowserCell browserCell = new NSBrowserCell (cell); browserCell.setImage (image !is null ? image.handle : null); browserCell.setFont (item.getFont (columnIndex).handle); - + if (hooks (DWT.MeasureItem)) { NSOutlineView view = cast(NSOutlineView)this.view; NSInteger nsColumnIndex = view.columnWithIdentifier (new cocoa.id (tableColumn)); @@ -1705,7 +1705,7 @@ NSRect rect = view.frameOfCellAtColumn (nsColumnIndex, rowIndex); NSRect contentRect = browserCell.titleRectForBounds (rect); NSSize contentSize = browserCell.cellSizeForBounds (rect); - + GCData data = new GCData (); data.paintRectStruct = view.frame (); data.paintRect = &data.paintRectStruct; @@ -1763,14 +1763,14 @@ cocoa.id columnId = userInfo.valueForKey (NSString.stringWith ("NSTableColumn")); //$NON-NLS-1$ TreeColumn column = getColumn (columnId); if (column is null) return; /* either CHECK column or firstColumn in 0-column Tree */ - + column.sendEvent (DWT.Resize); if (isDisposed ()) return; - + NSOutlineView outlineView = cast(NSOutlineView)view; NSInteger index = outlineView.columnWithIdentifier (columnId); if (index is -1) return; /* column was disposed in Resize callback */ - + NSArray nsColumns = outlineView.tableColumns (); NSInteger columnCount = outlineView.numberOfColumns (); for (NSInteger i = index + 1; i < columnCount; i++) { @@ -2124,7 +2124,7 @@ outlineView.moveColumn (oldIndex, newIndex); newX [index] = cast(int)outlineView.rectOfColumn (newIndex).x; } - + TreeColumn[] newColumns = new TreeColumn [columnCount]; System.arraycopy (columns, 0, newColumns, 0, columnCount); for (int i=0; i<columnCount; i++) { @@ -2232,20 +2232,20 @@ 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); } } void setItemHeight (Image image) { -// Rectangle bounds = image !is null ? image.getBounds () : imageBounds; -// if (bounds is null) return; -// imageBounds = bounds; -// short [] height = new short [1]; -// if (OS.GetDataBrowserTableViewRowHeight (handle, height) is OS.noErr) { -// if (height [0] < bounds.height) { -// OS.SetDataBrowserTableViewRowHeight (handle, cast(short) bounds.height); -// } -// } + // Rectangle bounds = image !is null ? image.getBounds () : imageBounds; + // if (bounds is null) return; + // imageBounds = bounds; + // short [] height = new short [1]; + // if (OS.GetDataBrowserTableViewRowHeight (handle, height) is OS.noErr) { + // if (height [0] < bounds.height) { + // OS.SetDataBrowserTableViewRowHeight (handle, cast(short) bounds.height); + // } + // } } /** @@ -2289,10 +2289,10 @@ bool setScrollWidth (TreeItem[] items, bool recurse, bool callMeasureItem) { if (columnCount !is 0) return false; -// if (currentItem !is null) { -// if (currentItem !is item) fixScrollWidth = true; -// return false; -// } + // if (currentItem !is null) { + // if (currentItem !is item) fixScrollWidth = true; + // return false; + // } if (/*ignoreRedraw ||*/ drawCount !is 0) return false; int newWidth = 0; GC gc = new GC (this);