Mercurial > projects > dstep
diff dstep/appkit/NSControl.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/NSControl.d Sun Jan 03 22:06:11 2010 +0100 @@ -0,0 +1,465 @@ +/** + * 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.NSControl; + +import dstep.appkit.NSCell; +import dstep.appkit.NSEvent; +import dstep.appkit.NSFont; +import dstep.appkit.NSText; +import dstep.appkit.NSTextView; +import dstep.appkit.NSView; +import dstep.foundation.NSAttributedString; +import dstep.foundation.NSFormatter; +import dstep.foundation.NSGeometry; +import dstep.foundation.NSObjCRuntime; +import dstep.foundation.NSObject; +import dstep.foundation.NSNotification; +import dstep.foundation.NSString; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc; + +import bindings = dstep.appkit.NSControl_bindings; + +private +{ + NSString NSControlTextDidBeginEditingNotification_; + NSString NSControlTextDidEndEditingNotification_; + NSString NSControlTextDidChangeNotification_; +} + +NSString NSControlTextDidBeginEditingNotification () +{ + if (NSControlTextDidBeginEditingNotification_) + return NSControlTextDidBeginEditingNotification_; + + return NSControlTextDidBeginEditingNotification_ = new NSString(bindings.NSControlTextDidBeginEditingNotification); +} + +NSString NSControlTextDidEndEditingNotification () +{ + if (NSControlTextDidEndEditingNotification_) + return NSControlTextDidEndEditingNotification_; + + return NSControlTextDidEndEditingNotification_ = new NSString(bindings.NSControlTextDidEndEditingNotification); +} + +NSString NSControlTextDidChangeNotification () +{ + if (NSControlTextDidChangeNotification_) + return NSControlTextDidChangeNotification_; + + return NSControlTextDidChangeNotification_ = new NSString(bindings.NSControlTextDidChangeNotification); +} + +const TNSControlSubclassNotifications = ` + + void controlTextDidBeginEditing (NSNotification obj) + { + return invokeObjcSelf!(void, "controlTextDidBeginEditing:", NSNotification)(obj); + } + + void controlTextDidEndEditing (NSNotification obj) + { + return invokeObjcSelf!(void, "controlTextDidEndEditing:", NSNotification)(obj); + } + + void controlTextDidChange (NSNotification obj) + { + return invokeObjcSelf!(void, "controlTextDidChange:", NSNotification)(obj); + } + + //mixin ObjcBindMethod!(controlTextDidBeginEditing, "controlTextDidBeginEditing:"); + //mixin ObjcBindMethod!(controlTextDidEndEditing, "controlTextDidEndEditing:"); + //mixin ObjcBindMethod!(controlTextDidChange, "controlTextDidChange:"); + +`; + +const TNSControlAttributedStringMethods = ` + + NSAttributedString attributedStringValue () + { + return invokeObjcSelf!(NSAttributedString, "attributedStringValue"); + } + + void setAttributedStringValue (NSAttributedString obj) + { + return invokeObjcSelf!(void, "setAttributedStringValue:", NSAttributedString)(obj); + } + + //mixin ObjcBindMethod!(attributedStringValue, "attributedStringValue"); + //mixin ObjcBindMethod!(setAttributedStringValue, "setAttributedStringValue:"); + +`; + +const TNSControlSubclassDelegate = ` + + bool control (NSControl control, NSText fieldEditor) + { + return invokeObjcSelf!(bool, "control:textShouldBeginEditing:", NSControl, NSText)(control, fieldEditor); + } + + bool control (NSControl control, NSText fieldEditor) + { + return invokeObjcSelf!(bool, "control:textShouldEndEditing:", NSControl, NSText)(control, fieldEditor); + } + + bool control (NSControl control, NSString string, NSString error) + { + return invokeObjcSelf!(bool, "control:didFailToFormatString:errorDescription:", NSControl, NSString, NSString)(control, string, error); + } + + void control (NSControl control, NSString string, NSString error) + { + return invokeObjcSelf!(void, "control:didFailToValidatePartialString:errorDescription:", NSControl, NSString, NSString)(control, string, error); + } + + bool control (NSControl control, Object obj) + { + return invokeObjcSelf!(bool, "control:isValidObject:", NSControl, Object)(control, obj); + } + + bool control (NSControl control, NSTextView textView, SEL commandSelector) + { + return invokeObjcSelf!(bool, "control:textView:doCommandBySelector:", NSControl, NSTextView, SEL)(control, textView, commandSelector); + } + + NSArray control (NSControl control, NSTextView textView, NSArray words, NSRange charRange, NSInteger* index) + { + return invokeObjcSelf!(NSArray, "control:textView:completions:forPartialWordRange:indexOfSelectedItem:", NSControl, NSTextView, NSArray, NSRange, NSInteger*)(control, textView, words, charRange, index); + } + + //mixin ObjcBindMethod!(control, "control:textShouldBeginEditing:"); + //mixin ObjcBindMethod!(control, "control:textShouldEndEditing:"); + //mixin ObjcBindMethod!(control, "control:didFailToFormatString:errorDescription:"); + //mixin ObjcBindMethod!(control, "control:didFailToValidatePartialString:errorDescription:"); + //mixin ObjcBindMethod!(control, "control:isValidObject:"); + //mixin ObjcBindMethod!(control, "control:textView:doCommandBySelector:"); + //mixin ObjcBindMethod!(control, "control:textView:completions:forPartialWordRange:indexOfSelectedItem:"); + +`; + +class NSControl : NSView +{ + mixin (ObjcWrap); + + static void setCellClass (Class factoryId) + { + return invokeObjcSelfClass!(void, "setCellClass:", Class)(factoryId); + } + + static Class cellClass () + { + return invokeObjcSelfClass!(Class, "cellClass"); + } + + NSControl initWithFrame (NSRect frameRect) + { + id result = invokeObjcSelf!(id, "initWithFrame:", NSRect)(frameRect); + return result is this.objcObject ? this : (result !is null ? new NSControl(result) : null); + } + + this (NSRect frameRect) + { + super(NSControl.alloc.initWithFrame(frameRect).objcObject); + } + + void sizeToFit () + { + return invokeObjcSelf!(void, "sizeToFit"); + } + + void calcSize () + { + return invokeObjcSelf!(void, "calcSize"); + } + + Object cell () + { + return invokeObjcSelf!(Object, "cell"); + } + + void setCell (NSCell aCell) + { + return invokeObjcSelf!(void, "setCell:", NSCell)(aCell); + } + + Object selectedCell () + { + return invokeObjcSelf!(Object, "selectedCell"); + } + + Object target () + { + return invokeObjcSelf!(Object, "target"); + } + + void setTarget (Object anObject) + { + return invokeObjcSelf!(void, "setTarget:", Object)(anObject); + } + + SEL action () + { + return invokeObjcSelf!(SEL, "action"); + } + + void setAction (SEL aSelector) + { + return invokeObjcSelf!(void, "setAction:", SEL)(aSelector); + } + + NSInteger tag () + { + return invokeObjcSelf!(NSInteger, "tag"); + } + + void setTag (NSInteger anInt) + { + return invokeObjcSelf!(void, "setTag:", NSInteger)(anInt); + } + + NSInteger selectedTag () + { + return invokeObjcSelf!(NSInteger, "selectedTag"); + } + + void setIgnoresMultiClick (bool flag) + { + return invokeObjcSelf!(void, "setIgnoresMultiClick:", bool)(flag); + } + + bool ignoresMultiClick () + { + return invokeObjcSelf!(bool, "ignoresMultiClick"); + } + + NSInteger sendActionOn (NSInteger mask) + { + return invokeObjcSelf!(NSInteger, "sendActionOn:", NSInteger)(mask); + } + + bool isContinuous () + { + return invokeObjcSelf!(bool, "isContinuous"); + } + + void setContinuous (bool flag) + { + return invokeObjcSelf!(void, "setContinuous:", bool)(flag); + } + + bool isEnabled () + { + return invokeObjcSelf!(bool, "isEnabled"); + } + + void setEnabled (bool flag) + { + return invokeObjcSelf!(void, "setEnabled:", bool)(flag); + } + + void setFloatingPointFormat (bool autoRange, NSUInteger leftDigits, NSUInteger rightDigits) + { + return invokeObjcSelf!(void, "setFloatingPointFormat:left:right:", bool, NSUInteger, NSUInteger)(autoRange, leftDigits, rightDigits); + } + + uint alignment () + { + return invokeObjcSelf!(uint, "alignment"); + } + + void setAlignment (uint mode) + { + return invokeObjcSelf!(void, "setAlignment:", uint)(mode); + } + + NSFont font () + { + return invokeObjcSelf!(NSFont, "font"); + } + + void setFont (NSFont fontObj) + { + return invokeObjcSelf!(void, "setFont:", NSFont)(fontObj); + } + + void setFormatter (NSFormatter newFormatter) + { + return invokeObjcSelf!(void, "setFormatter:", NSFormatter)(newFormatter); + } + + Object formatter () + { + return invokeObjcSelf!(Object, "formatter"); + } + + void setObjectValue (INSCopying obj) + { + return invokeObjcSelf!(void, "setObjectValue:", INSCopying)(obj); + } + + void setStringValue (NSString aString) + { + return invokeObjcSelf!(void, "setStringValue:", NSString)(aString); + } + + void setIntValue (int anInt) + { + return invokeObjcSelf!(void, "setIntValue:", int)(anInt); + } + + void setFloatValue (float aFloat) + { + return invokeObjcSelf!(void, "setFloatValue:", float)(aFloat); + } + + void setDoubleValue (double aDouble) + { + return invokeObjcSelf!(void, "setDoubleValue:", double)(aDouble); + } + + Object objectValue () + { + return invokeObjcSelf!(Object, "objectValue"); + } + + NSString stringValue () + { + return invokeObjcSelf!(NSString, "stringValue"); + } + + int intValue () + { + return invokeObjcSelf!(int, "intValue"); + } + + float floatValue () + { + return invokeObjcSelf!(float, "floatValue"); + } + + double doubleValue () + { + return invokeObjcSelf!(double, "doubleValue"); + } + + void setNeedsDisplay () + { + return invokeObjcSelf!(void, "setNeedsDisplay"); + } + + void updateCell (NSCell aCell) + { + return invokeObjcSelf!(void, "updateCell:", NSCell)(aCell); + } + + void updateCellInside (NSCell aCell) + { + return invokeObjcSelf!(void, "updateCellInside:", NSCell)(aCell); + } + + void drawCellInside (NSCell aCell) + { + return invokeObjcSelf!(void, "drawCellInside:", NSCell)(aCell); + } + + void drawCell (NSCell aCell) + { + return invokeObjcSelf!(void, "drawCell:", NSCell)(aCell); + } + + void selectCell (NSCell aCell) + { + return invokeObjcSelf!(void, "selectCell:", NSCell)(aCell); + } + + bool sendAction (SEL theAction, Object theTarget) + { + return invokeObjcSelf!(bool, "sendAction:to:", SEL, Object)(theAction, theTarget); + } + + void takeIntValueFrom (Object sender) + { + return invokeObjcSelf!(void, "takeIntValueFrom:", Object)(sender); + } + + void takeFloatValueFrom (Object sender) + { + return invokeObjcSelf!(void, "takeFloatValueFrom:", Object)(sender); + } + + void takeDoubleValueFrom (Object sender) + { + return invokeObjcSelf!(void, "takeDoubleValueFrom:", Object)(sender); + } + + void takeStringValueFrom (Object sender) + { + return invokeObjcSelf!(void, "takeStringValueFrom:", Object)(sender); + } + + void takeObjectValueFrom (Object sender) + { + return invokeObjcSelf!(void, "takeObjectValueFrom:", Object)(sender); + } + + NSText currentEditor () + { + return invokeObjcSelf!(NSText, "currentEditor"); + } + + bool abortEditing () + { + return invokeObjcSelf!(bool, "abortEditing"); + } + + void validateEditing () + { + return invokeObjcSelf!(void, "validateEditing"); + } + + void mouseDown (NSEvent theEvent) + { + return invokeObjcSelf!(void, "mouseDown:", NSEvent)(theEvent); + } + + int baseWritingDirection () + { + return invokeObjcSelf!(int, "baseWritingDirection"); + } + + void setBaseWritingDirection (int writingDirection) + { + return invokeObjcSelf!(void, "setBaseWritingDirection:", int)(writingDirection); + } + + NSInteger integerValue () + { + return invokeObjcSelf!(NSInteger, "integerValue"); + } + + void setIntegerValue (NSInteger anInteger) + { + return invokeObjcSelf!(void, "setIntegerValue:", NSInteger)(anInteger); + } + + void takeIntegerValueFrom (Object sender) + { + return invokeObjcSelf!(void, "takeIntegerValueFrom:", Object)(sender); + } + + // NSControlAttributedStringMethods + NSAttributedString attributedStringValue () + { + return invokeObjcSelf!(NSAttributedString, "attributedStringValue"); + } + + void setAttributedStringValue (NSAttributedString obj) + { + return invokeObjcSelf!(void, "setAttributedStringValue:", NSAttributedString)(obj); + } +} \ No newline at end of file