Mercurial > projects > dstep
diff dstep/appkit/NSComboBox.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/NSComboBox.d Sun Jan 03 22:06:11 2010 +0100 @@ -0,0 +1,297 @@ +/** + * 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.NSComboBox; + +import dstep.appkit.NSTextField; +import dstep.applicationservices.coregraphics.CGBase; +import dstep.foundation.NSArray; +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.NSComboBox_bindings; + +private +{ + NSString NSComboBoxWillPopUpNotification_; + NSString NSComboBoxWillDismissNotification_; + NSString NSComboBoxSelectionDidChangeNotification_; + NSString NSComboBoxSelectionIsChangingNotification_; +} + +NSString NSComboBoxWillPopUpNotification () +{ + if (NSComboBoxWillPopUpNotification_) + return NSComboBoxWillPopUpNotification_; + + return NSComboBoxWillPopUpNotification_ = new NSString(bindings.NSComboBoxWillPopUpNotification); +} + +NSString NSComboBoxWillDismissNotification () +{ + if (NSComboBoxWillDismissNotification_) + return NSComboBoxWillDismissNotification_; + + return NSComboBoxWillDismissNotification_ = new NSString(bindings.NSComboBoxWillDismissNotification); +} + +NSString NSComboBoxSelectionDidChangeNotification () +{ + if (NSComboBoxSelectionDidChangeNotification_) + return NSComboBoxSelectionDidChangeNotification_; + + return NSComboBoxSelectionDidChangeNotification_ = new NSString(bindings.NSComboBoxSelectionDidChangeNotification); +} + +NSString NSComboBoxSelectionIsChangingNotification () +{ + if (NSComboBoxSelectionIsChangingNotification_) + return NSComboBoxSelectionIsChangingNotification_; + + return NSComboBoxSelectionIsChangingNotification_ = new NSString(bindings.NSComboBoxSelectionIsChangingNotification); +} + +class NSComboBox : NSTextField +{ + mixin (ObjcWrap); + + bool hasVerticalScroller () + { + return invokeObjcSelf!(bool, "hasVerticalScroller"); + } + + void setHasVerticalScroller (bool flag) + { + return invokeObjcSelf!(void, "setHasVerticalScroller:", bool)(flag); + } + + NSSize intercellSpacing () + { + return invokeObjcSelf!(NSSize, "intercellSpacing"); + } + + void setIntercellSpacing (NSSize aSize) + { + return invokeObjcSelf!(void, "setIntercellSpacing:", NSSize)(aSize); + } + + CGFloat itemHeight () + { + return invokeObjcSelf!(CGFloat, "itemHeight"); + } + + void setItemHeight (CGFloat itemHeight) + { + return invokeObjcSelf!(void, "setItemHeight:", CGFloat)(itemHeight); + } + + NSInteger numberOfVisibleItems () + { + return invokeObjcSelf!(NSInteger, "numberOfVisibleItems"); + } + + void setNumberOfVisibleItems (NSInteger visibleItems) + { + return invokeObjcSelf!(void, "setNumberOfVisibleItems:", NSInteger)(visibleItems); + } + + void setButtonBordered (bool flag) + { + return invokeObjcSelf!(void, "setButtonBordered:", bool)(flag); + } + + bool isButtonBordered () + { + return invokeObjcSelf!(bool, "isButtonBordered"); + } + + void reloadData () + { + return invokeObjcSelf!(void, "reloadData"); + } + + void noteNumberOfItemsChanged () + { + return invokeObjcSelf!(void, "noteNumberOfItemsChanged"); + } + + void setUsesDataSource (bool flag) + { + return invokeObjcSelf!(void, "setUsesDataSource:", bool)(flag); + } + + bool usesDataSource () + { + return invokeObjcSelf!(bool, "usesDataSource"); + } + + void scrollItemAtIndexToTop (NSInteger index) + { + return invokeObjcSelf!(void, "scrollItemAtIndexToTop:", NSInteger)(index); + } + + void scrollItemAtIndexToVisible (NSInteger index) + { + return invokeObjcSelf!(void, "scrollItemAtIndexToVisible:", NSInteger)(index); + } + + void selectItemAtIndex (NSInteger index) + { + return invokeObjcSelf!(void, "selectItemAtIndex:", NSInteger)(index); + } + + void deselectItemAtIndex (NSInteger index) + { + return invokeObjcSelf!(void, "deselectItemAtIndex:", NSInteger)(index); + } + + NSInteger indexOfSelectedItem () + { + return invokeObjcSelf!(NSInteger, "indexOfSelectedItem"); + } + + NSInteger numberOfItems () + { + return invokeObjcSelf!(NSInteger, "numberOfItems"); + } + + bool completes () + { + return invokeObjcSelf!(bool, "completes"); + } + + void setCompletes (bool completes) + { + return invokeObjcSelf!(void, "setCompletes:", bool)(completes); + } + + Object dataSource () + { + return invokeObjcSelf!(Object, "dataSource"); + } + + void setDataSource (Object aSource) + { + return invokeObjcSelf!(void, "setDataSource:", Object)(aSource); + } + + void addItemWithObjectValue (Object object) + { + return invokeObjcSelf!(void, "addItemWithObjectValue:", Object)(object); + } + + void addItemsWithObjectValues (NSArray objects) + { + return invokeObjcSelf!(void, "addItemsWithObjectValues:", NSArray)(objects); + } + + void insertItemWithObjectValue (Object object, NSInteger index) + { + return invokeObjcSelf!(void, "insertItemWithObjectValue:atIndex:", Object, NSInteger)(object, index); + } + + void removeItemWithObjectValue (Object object) + { + return invokeObjcSelf!(void, "removeItemWithObjectValue:", Object)(object); + } + + void removeItemAtIndex (NSInteger index) + { + return invokeObjcSelf!(void, "removeItemAtIndex:", NSInteger)(index); + } + + void removeAllItems () + { + return invokeObjcSelf!(void, "removeAllItems"); + } + + void selectItemWithObjectValue (Object object) + { + return invokeObjcSelf!(void, "selectItemWithObjectValue:", Object)(object); + } + + Object itemObjectValueAtIndex (NSInteger index) + { + return invokeObjcSelf!(Object, "itemObjectValueAtIndex:", NSInteger)(index); + } + + Object objectValueOfSelectedItem () + { + return invokeObjcSelf!(Object, "objectValueOfSelectedItem"); + } + + NSInteger indexOfItemWithObjectValue (Object object) + { + return invokeObjcSelf!(NSInteger, "indexOfItemWithObjectValue:", Object)(object); + } + + NSArray objectValues () + { + return invokeObjcSelf!(NSArray, "objectValues"); + } +} + +const TNSComboBoxDataSource = ` + + NSInteger numberOfItemsInComboBox (NSComboBox aComboBox) + { + return invokeObjcSelf!(NSInteger, "numberOfItemsInComboBox:", NSComboBox)(aComboBox); + } + + Object comboBox (NSComboBox aComboBox, NSInteger index) + { + return invokeObjcSelf!(Object, "comboBox:objectValueForItemAtIndex:", NSComboBox, NSInteger)(aComboBox, index); + } + + NSUInteger comboBox (NSComboBox aComboBox, NSString string) + { + return invokeObjcSelf!(NSUInteger, "comboBox:indexOfItemWithStringValue:", NSComboBox, NSString)(aComboBox, string); + } + + NSString comboBox (NSComboBox aComboBox, NSString string) + { + return invokeObjcSelf!(NSString, "comboBox:completedString:", NSComboBox, NSString)(aComboBox, string); + } + + //mixin ObjcBindMethod!(numberOfItemsInComboBox, "numberOfItemsInComboBox:"); + //mixin ObjcBindMethod!(comboBox, "comboBox:objectValueForItemAtIndex:"); + //mixin ObjcBindMethod!(comboBox, "comboBox:indexOfItemWithStringValue:"); + //mixin ObjcBindMethod!(comboBox, "comboBox:completedString:"); + +`; + +const TNSComboBoxNotifications = ` + + void comboBoxWillPopUp (NSNotification notification) + { + return invokeObjcSelf!(void, "comboBoxWillPopUp:", NSNotification)(notification); + } + + void comboBoxWillDismiss (NSNotification notification) + { + return invokeObjcSelf!(void, "comboBoxWillDismiss:", NSNotification)(notification); + } + + void comboBoxSelectionDidChange (NSNotification notification) + { + return invokeObjcSelf!(void, "comboBoxSelectionDidChange:", NSNotification)(notification); + } + + void comboBoxSelectionIsChanging (NSNotification notification) + { + return invokeObjcSelf!(void, "comboBoxSelectionIsChanging:", NSNotification)(notification); + } + + //mixin ObjcBindMethod!(comboBoxWillPopUp, "comboBoxWillPopUp:"); + //mixin ObjcBindMethod!(comboBoxWillDismiss, "comboBoxWillDismiss:"); + //mixin ObjcBindMethod!(comboBoxSelectionDidChange, "comboBoxSelectionDidChange:"); + //mixin ObjcBindMethod!(comboBoxSelectionIsChanging, "comboBoxSelectionIsChanging:"); + +`; +