Mercurial > projects > dstep
diff dstep/appkit/NSOutlineView.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dstep/appkit/NSOutlineView.d Sun Jan 03 22:06:11 2010 +0100 @@ -0,0 +1,525 @@ +/** + * Copyright: Copyright (c) 2009 Jacob Carlborg. + * Authors: Jacob Carlborg + * Version: Initial created: Sep 24, 2009 + * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) + */ +module dstep.appkit.NSOutlineView; + +import dstep.appkit.AppKitDefines; +import dstep.appkit.NSButtonCell; +import dstep.appkit.NSTableColumn; +import dstep.appkit.NSTableHeaderView; +import dstep.appkit.NSTableView; +import dstep.applicationservices.coregraphics.CGBase; +import dstep.corefoundation.CFDictionary; +import dstep.foundation.NSGeometry; +import dstep.foundation.NSObjCRuntime; +import dstep.foundation.NSString; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc; + +import bindings = dstep.appkit.NSOutlineView_bindings; + +private +{ + NSString NSOutlineViewSelectionDidChangeNotification_; + NSString NSOutlineViewColumnDidMoveNotification_; + NSString NSOutlineViewColumnDidResizeNotification_; + NSString NSOutlineViewSelectionIsChangingNotification_; + NSString NSOutlineViewItemWillExpandNotification_; + NSString NSOutlineViewItemDidExpandNotification_; + NSString NSOutlineViewItemWillCollapseNotification_; + NSString NSOutlineViewItemDidCollapseNotification_; +} + +NSString NSOutlineViewSelectionDidChangeNotification () +{ + if (NSOutlineViewSelectionDidChangeNotification_) + return NSOutlineViewSelectionDidChangeNotification_; + + return NSOutlineViewSelectionDidChangeNotification_ = new NSString(bindings.NSOutlineViewSelectionDidChangeNotification); +} + +NSString NSOutlineViewColumnDidMoveNotification () +{ + if (NSOutlineViewColumnDidMoveNotification_) + return NSOutlineViewColumnDidMoveNotification_; + + return NSOutlineViewColumnDidMoveNotification_ = new NSString(bindings.NSOutlineViewColumnDidMoveNotification); +} + +NSString NSOutlineViewColumnDidResizeNotification () +{ + if (NSOutlineViewColumnDidResizeNotification_) + return NSOutlineViewColumnDidResizeNotification_; + + return NSOutlineViewColumnDidResizeNotification_ = new NSString(bindings.NSOutlineViewColumnDidResizeNotification); +} + +NSString NSOutlineViewSelectionIsChangingNotification () +{ + if (NSOutlineViewSelectionIsChangingNotification_) + return NSOutlineViewSelectionIsChangingNotification_; + + return NSOutlineViewSelectionIsChangingNotification_ = new NSString(bindings.NSOutlineViewSelectionIsChangingNotification); +} + +NSString NSOutlineViewItemWillExpandNotification () +{ + if (NSOutlineViewItemWillExpandNotification_) + return NSOutlineViewItemWillExpandNotification_; + + return NSOutlineViewItemWillExpandNotification_ = new NSString(bindings.NSOutlineViewItemWillExpandNotification); +} + +NSString NSOutlineViewItemDidExpandNotification () +{ + if (NSOutlineViewItemDidExpandNotification_) + return NSOutlineViewItemDidExpandNotification_; + + return NSOutlineViewItemDidExpandNotification_ = new NSString(bindings.NSOutlineViewItemDidExpandNotification); +} + +NSString NSOutlineViewItemWillCollapseNotification () +{ + if (NSOutlineViewItemWillCollapseNotification_) + return NSOutlineViewItemWillCollapseNotification_; + + return NSOutlineViewItemWillCollapseNotification_ = new NSString(bindings.NSOutlineViewItemWillCollapseNotification); +} + +NSString NSOutlineViewItemDidCollapseNotification () +{ + if (NSOutlineViewItemDidCollapseNotification_) + return NSOutlineViewItemDidCollapseNotification_; + + return NSOutlineViewItemDidCollapseNotification_ = new NSString(bindings.NSOutlineViewItemDidCollapseNotification); +} + +enum +{ + NSOutlineViewDropOnItemIndex = -1 +} + +struct _OVFlags +{ + uint _reserved; + uint reloadingData; + uint validDataSourceMethods; + uint numberOfRowsDataExpandEntered; + uint delayRowEntryFreeDisabled; + uint delegateHeightOfRowByItem; + uint compatCollapseForceClearsExpandState; + uint autoExpandFlashState; + uint selectionAdjustmentDisabled; + uint removeChildInProgress; + uint delegateWillDisplayOutlineCell; + uint enableExpandNotifications; + uint autoSaveExpandItems; + uint autoresizesOutlineColumn; + uint delegateShouldExpandItem; + uint delegateShouldCollapseItem; + uint delegateSelectionShouldChangeInOutlineView; + uint delegateShouldSelectTableColumn; + uint delegateShouldSelectItem; + uint delegateShouldEditTableColumn; + uint delegateWillDisplayCell; +} + +class NSOutlineView : NSTableView +{ + mixin (ObjcWrap); + + void setOutlineTableColumn (NSTableColumn outlineTableColumn) + { + return invokeObjcSelf!(void, "setOutlineTableColumn:", NSTableColumn)(outlineTableColumn); + } + + NSTableColumn outlineTableColumn () + { + return invokeObjcSelf!(NSTableColumn, "outlineTableColumn"); + } + + bool isExpandable (Object item) + { + return invokeObjcSelf!(bool, "isExpandable:", Object)(item); + } + + void expandItem (Object item, bool expandChildren) + { + return invokeObjcSelf!(void, "expandItem:expandChildren:", Object, bool)(item, expandChildren); + } + + void expandItem (Object item) + { + return invokeObjcSelf!(void, "expandItem:", Object)(item); + } + + void collapseItem (Object item, bool collapseChildren) + { + return invokeObjcSelf!(void, "collapseItem:collapseChildren:", Object, bool)(item, collapseChildren); + } + + void collapseItem (Object item) + { + return invokeObjcSelf!(void, "collapseItem:", Object)(item); + } + + void reloadItem (Object item, bool reloadChildren) + { + return invokeObjcSelf!(void, "reloadItem:reloadChildren:", Object, bool)(item, reloadChildren); + } + + void reloadItem (Object item) + { + return invokeObjcSelf!(void, "reloadItem:", Object)(item); + } + + Object parentForItem (Object item) + { + return invokeObjcSelf!(Object, "parentForItem:", Object)(item); + } + + Object itemAtRow (NSInteger row) + { + return invokeObjcSelf!(Object, "itemAtRow:", NSInteger)(row); + } + + NSInteger rowForItem (Object item) + { + return invokeObjcSelf!(NSInteger, "rowForItem:", Object)(item); + } + + NSInteger levelForItem (Object item) + { + return invokeObjcSelf!(NSInteger, "levelForItem:", Object)(item); + } + + NSInteger levelForRow (NSInteger row) + { + return invokeObjcSelf!(NSInteger, "levelForRow:", NSInteger)(row); + } + + bool isItemExpanded (Object item) + { + return invokeObjcSelf!(bool, "isItemExpanded:", Object)(item); + } + + void setIndentationPerLevel (CGFloat indentationPerLevel) + { + return invokeObjcSelf!(void, "setIndentationPerLevel:", CGFloat)(indentationPerLevel); + } + + CGFloat indentationPerLevel () + { + return invokeObjcSelf!(CGFloat, "indentationPerLevel"); + } + + void setIndentationMarkerFollowsCell (bool drawInCell) + { + return invokeObjcSelf!(void, "setIndentationMarkerFollowsCell:", bool)(drawInCell); + } + + bool indentationMarkerFollowsCell () + { + return invokeObjcSelf!(bool, "indentationMarkerFollowsCell"); + } + + void setAutoresizesOutlineColumn (bool resize) + { + return invokeObjcSelf!(void, "setAutoresizesOutlineColumn:", bool)(resize); + } + + bool autoresizesOutlineColumn () + { + return invokeObjcSelf!(bool, "autoresizesOutlineColumn"); + } + + NSRect frameOfOutlineCellAtRow (NSInteger row) + { + return invokeObjcSelf!(NSRect, "frameOfOutlineCellAtRow:", NSInteger)(row); + } + + void setDropItem (Object item, NSInteger index) + { + return invokeObjcSelf!(void, "setDropItem:dropChildIndex:", Object, NSInteger)(item, index); + } + + bool shouldCollapseAutoExpandedItemsForDeposited (bool deposited) + { + return invokeObjcSelf!(bool, "shouldCollapseAutoExpandedItemsForDeposited:", bool)(deposited); + } + + bool autosaveExpandedItems () + { + return invokeObjcSelf!(bool, "autosaveExpandedItems"); + } + + void setAutosaveExpandedItems (bool save) + { + return invokeObjcSelf!(void, "setAutosaveExpandedItems:", bool)(save); + } +} + +const TNSOutlineViewDataSource = ` + + Object outlineView (NSOutlineView outlineView, NSInteger index, Object item) + { + return invokeObjcSelf!(Object, "outlineView:child:ofItem:", NSOutlineView, NSInteger, Object)(outlineView, index, item); + } + + bool outlineView (NSOutlineView outlineView, Object item) + { + return invokeObjcSelf!(bool, "outlineView:isItemExpandable:", NSOutlineView, Object)(outlineView, item); + } + + NSInteger outlineView (NSOutlineView outlineView, Object item) + { + return invokeObjcSelf!(NSInteger, "outlineView:numberOfChildrenOfItem:", NSOutlineView, Object)(outlineView, item); + } + + Object outlineView (NSOutlineView outlineView, NSTableColumn tableColumn, Object item) + { + return invokeObjcSelf!(Object, "outlineView:objectValueForTableColumn:byItem:", NSOutlineView, NSTableColumn, Object)(outlineView, tableColumn, item); + } + + void outlineView (NSOutlineView outlineView, Object object, NSTableColumn tableColumn, Object item) + { + return invokeObjcSelf!(void, "outlineView:setObjectValue:forTableColumn:byItem:", NSOutlineView, Object, NSTableColumn, Object)(outlineView, object, tableColumn, item); + } + + Object outlineView (NSOutlineView outlineView, Object object) + { + return invokeObjcSelf!(Object, "outlineView:itemForPersistentObject:", NSOutlineView, Object)(outlineView, object); + } + + Object outlineView (NSOutlineView outlineView, Object item) + { + return invokeObjcSelf!(Object, "outlineView:persistentObjectForItem:", NSOutlineView, Object)(outlineView, item); + } + + void outlineView (NSOutlineView outlineView, NSArray oldDescriptors) + { + return invokeObjcSelf!(void, "outlineView:sortDescriptorsDidChange:", NSOutlineView, NSArray)(outlineView, oldDescriptors); + } + + bool outlineView (NSOutlineView outlineView, NSArray items, NSPasteboard pasteboard) + { + return invokeObjcSelf!(bool, "outlineView:writeItems:toPasteboard:", NSOutlineView, NSArray, NSPasteboard)(outlineView, items, pasteboard); + } + + uint outlineView (NSOutlineView outlineView, INSDraggingInfo info, Object item, NSInteger index) + { + return invokeObjcSelf!(uint, "outlineView:validateDrop:proposedItem:proposedChildIndex:", NSOutlineView, INSDraggingInfo, Object, NSInteger)(outlineView, info, item, index); + } + + bool outlineView (NSOutlineView outlineView, INSDraggingInfo info, Object item, NSInteger index) + { + return invokeObjcSelf!(bool, "outlineView:acceptDrop:item:childIndex:", NSOutlineView, INSDraggingInfo, Object, NSInteger)(outlineView, info, item, index); + } + + NSArray outlineView (NSOutlineView outlineView, NSURL dropDestination, NSArray items) + { + return invokeObjcSelf!(NSArray, "outlineView:namesOfPromisedFilesDroppedAtDestination:forDraggedItems:", NSOutlineView, NSURL, NSArray)(outlineView, dropDestination, items); + } + + //mixin ObjcBindMethod!(outlineView, "outlineView:child:ofItem:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:isItemExpandable:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:numberOfChildrenOfItem:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:objectValueForTableColumn:byItem:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:setObjectValue:forTableColumn:byItem:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:itemForPersistentObject:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:persistentObjectForItem:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:sortDescriptorsDidChange:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:writeItems:toPasteboard:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:validateDrop:proposedItem:proposedChildIndex:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:acceptDrop:item:childIndex:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:namesOfPromisedFilesDroppedAtDestination:forDraggedItems:"); + +`; + +const TNSOutlineViewNotifications = ` + + void outlineViewSelectionDidChange (NSNotification notification) + { + return invokeObjcSelf!(void, "outlineViewSelectionDidChange:", NSNotification)(notification); + } + + void outlineViewColumnDidMove (NSNotification notification) + { + return invokeObjcSelf!(void, "outlineViewColumnDidMove:", NSNotification)(notification); + } + + void outlineViewColumnDidResize (NSNotification notification) + { + return invokeObjcSelf!(void, "outlineViewColumnDidResize:", NSNotification)(notification); + } + + void outlineViewSelectionIsChanging (NSNotification notification) + { + return invokeObjcSelf!(void, "outlineViewSelectionIsChanging:", NSNotification)(notification); + } + + void outlineViewItemWillExpand (NSNotification notification) + { + return invokeObjcSelf!(void, "outlineViewItemWillExpand:", NSNotification)(notification); + } + + void outlineViewItemDidExpand (NSNotification notification) + { + return invokeObjcSelf!(void, "outlineViewItemDidExpand:", NSNotification)(notification); + } + + void outlineViewItemWillCollapse (NSNotification notification) + { + return invokeObjcSelf!(void, "outlineViewItemWillCollapse:", NSNotification)(notification); + } + + void outlineViewItemDidCollapse (NSNotification notification) + { + return invokeObjcSelf!(void, "outlineViewItemDidCollapse:", NSNotification)(notification); + } + + //mixin ObjcBindMethod!(outlineViewSelectionDidChange, "outlineViewSelectionDidChange:"); + //mixin ObjcBindMethod!(outlineViewColumnDidMove, "outlineViewColumnDidMove:"); + //mixin ObjcBindMethod!(outlineViewColumnDidResize, "outlineViewColumnDidResize:"); + //mixin ObjcBindMethod!(outlineViewSelectionIsChanging, "outlineViewSelectionIsChanging:"); + //mixin ObjcBindMethod!(outlineViewItemWillExpand, "outlineViewItemWillExpand:"); + //mixin ObjcBindMethod!(outlineViewItemDidExpand, "outlineViewItemDidExpand:"); + //mixin ObjcBindMethod!(outlineViewItemWillCollapse, "outlineViewItemWillCollapse:"); + //mixin ObjcBindMethod!(outlineViewItemDidCollapse, "outlineViewItemDidCollapse:"); + +`; + +const TNSOutlineViewDelegate = ` + + void outlineView (NSOutlineView outlineView, Object cell, NSTableColumn tableColumn, Object item) + { + return invokeObjcSelf!(void, "outlineView:willDisplayCell:forTableColumn:item:", NSOutlineView, Object, NSTableColumn, Object)(outlineView, cell, tableColumn, item); + } + + bool outlineView (NSOutlineView outlineView, NSTableColumn tableColumn, Object item) + { + return invokeObjcSelf!(bool, "outlineView:shouldEditTableColumn:item:", NSOutlineView, NSTableColumn, Object)(outlineView, tableColumn, item); + } + + bool selectionShouldChangeInOutlineView (NSOutlineView outlineView) + { + return invokeObjcSelf!(bool, "selectionShouldChangeInOutlineView:", NSOutlineView)(outlineView); + } + + bool outlineView (NSOutlineView outlineView, Object item) + { + return invokeObjcSelf!(bool, "outlineView:shouldSelectItem:", NSOutlineView, Object)(outlineView, item); + } + + NSIndexSet outlineView (NSOutlineView outlineView, NSIndexSet proposedSelectionIndexes) + { + return invokeObjcSelf!(NSIndexSet, "outlineView:selectionIndexesForProposedSelection:", NSOutlineView, NSIndexSet)(outlineView, proposedSelectionIndexes); + } + + bool outlineView (NSOutlineView outlineView, NSTableColumn tableColumn) + { + return invokeObjcSelf!(bool, "outlineView:shouldSelectTableColumn:", NSOutlineView, NSTableColumn)(outlineView, tableColumn); + } + + void outlineView (NSOutlineView outlineView, NSTableColumn tableColumn) + { + return invokeObjcSelf!(void, "outlineView:mouseDownInHeaderOfTableColumn:", NSOutlineView, NSTableColumn)(outlineView, tableColumn); + } + + void outlineView (NSOutlineView outlineView, NSTableColumn tableColumn) + { + return invokeObjcSelf!(void, "outlineView:didClickTableColumn:", NSOutlineView, NSTableColumn)(outlineView, tableColumn); + } + + void outlineView (NSOutlineView outlineView, NSTableColumn tableColumn) + { + return invokeObjcSelf!(void, "outlineView:didDragTableColumn:", NSOutlineView, NSTableColumn)(outlineView, tableColumn); + } + + NSString outlineView (NSOutlineView outlineView, NSCell cell, NSRectPointer rect, NSTableColumn tableColumn, Object item, NSPoint mouseLocation) + { + return invokeObjcSelf!(NSString, "outlineView:toolTipForCell:rect:tableColumn:item:mouseLocation:", NSOutlineView, NSCell, NSRectPointer, NSTableColumn, Object, NSPoint)(outlineView, cell, rect, tableColumn, item, mouseLocation); + } + + CGFloat outlineView (NSOutlineView outlineView, Object item) + { + return invokeObjcSelf!(CGFloat, "outlineView:heightOfRowByItem:", NSOutlineView, Object)(outlineView, item); + } + + NSString outlineView (NSOutlineView outlineView, NSTableColumn tableColumn, Object item) + { + return invokeObjcSelf!(NSString, "outlineView:typeSelectStringForTableColumn:item:", NSOutlineView, NSTableColumn, Object)(outlineView, tableColumn, item); + } + + Object outlineView (NSOutlineView outlineView, Object startItem, Object endItem, NSString searchString) + { + return invokeObjcSelf!(Object, "outlineView:nextTypeSelectMatchFromItem:toItem:forString:", NSOutlineView, Object, Object, NSString)(outlineView, startItem, endItem, searchString); + } + + bool outlineView (NSOutlineView outlineView, NSEvent event, NSString searchString) + { + return invokeObjcSelf!(bool, "outlineView:shouldTypeSelectForEvent:withCurrentSearchString:", NSOutlineView, NSEvent, NSString)(outlineView, event, searchString); + } + + bool outlineView (NSOutlineView outlineView, NSTableColumn tableColumn, Object item) + { + return invokeObjcSelf!(bool, "outlineView:shouldShowCellExpansionForTableColumn:item:", NSOutlineView, NSTableColumn, Object)(outlineView, tableColumn, item); + } + + bool outlineView (NSOutlineView outlineView, NSCell cell, NSTableColumn tableColumn, Object item) + { + return invokeObjcSelf!(bool, "outlineView:shouldTrackCell:forTableColumn:item:", NSOutlineView, NSCell, NSTableColumn, Object)(outlineView, cell, tableColumn, item); + } + + NSCell outlineView (NSOutlineView outlineView, NSTableColumn tableColumn, Object item) + { + return invokeObjcSelf!(NSCell, "outlineView:dataCellForTableColumn:item:", NSOutlineView, NSTableColumn, Object)(outlineView, tableColumn, item); + } + + bool outlineView (NSOutlineView outlineView, Object item) + { + return invokeObjcSelf!(bool, "outlineView:isGroupItem:", NSOutlineView, Object)(outlineView, item); + } + + bool outlineView (NSOutlineView outlineView, Object item) + { + return invokeObjcSelf!(bool, "outlineView:shouldExpandItem:", NSOutlineView, Object)(outlineView, item); + } + + bool outlineView (NSOutlineView outlineView, Object item) + { + return invokeObjcSelf!(bool, "outlineView:shouldCollapseItem:", NSOutlineView, Object)(outlineView, item); + } + + void outlineView (NSOutlineView outlineView, Object cell, NSTableColumn tableColumn, Object item) + { + return invokeObjcSelf!(void, "outlineView:willDisplayOutlineCell:forTableColumn:item:", NSOutlineView, Object, NSTableColumn, Object)(outlineView, cell, tableColumn, item); + } + + //mixin ObjcBindMethod!(outlineView, "outlineView:willDisplayCell:forTableColumn:item:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:shouldEditTableColumn:item:"); + //mixin ObjcBindMethod!(selectionShouldChangeInOutlineView, "selectionShouldChangeInOutlineView:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:shouldSelectItem:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:selectionIndexesForProposedSelection:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:shouldSelectTableColumn:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:mouseDownInHeaderOfTableColumn:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:didClickTableColumn:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:didDragTableColumn:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:toolTipForCell:rect:tableColumn:item:mouseLocation:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:heightOfRowByItem:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:typeSelectStringForTableColumn:item:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:nextTypeSelectMatchFromItem:toItem:forString:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:shouldTypeSelectForEvent:withCurrentSearchString:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:shouldShowCellExpansionForTableColumn:item:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:shouldTrackCell:forTableColumn:item:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:dataCellForTableColumn:item:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:isGroupItem:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:shouldExpandItem:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:shouldCollapseItem:"); + //mixin ObjcBindMethod!(outlineView, "outlineView:willDisplayOutlineCell:forTableColumn:item:"); + +`; +