Mercurial > projects > dstep
diff dstep/appkit/NSTextAttachment.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/NSTextAttachment.d Sun Jan 03 22:06:11 2010 +0100 @@ -0,0 +1,118 @@ +/** + * 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.NSTextAttachment; + +import dstep.appkit.NSAttributedString; +import dstep.appkit.NSCell; +import dstep.appkit.NSEvent; +import dstep.appkit.NSFileWrapper; +import dstep.appkit.NSLayoutManager; +import dstep.appkit.NSTextContainer; +import dstep.appkit.NSView; +import dstep.foundation.NSCoder; +import dstep.foundation.NSGeometry; +import dstep.foundation.NSObjCRuntime; +import dstep.foundation.NSObject; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc; + +enum +{ + NSAttachmentCharacter = 0xfffc +} + +class NSTextAttachment : NSObject, INSCoding +{ + mixin (ObjcWrap); + + this (NSCoder aDecoder) + { + super(typeof(this).alloc.initWithCoder(aDecoder).objcObject); + } + + void encodeWithCoder (NSCoder aCoder) + { + return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); + } + + typeof(this) initWithCoder (NSCoder aDecoder) + { + return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder); + } + + NSTextAttachment initWithFileWrapper (NSFileWrapper fileWrapper) + { + id result = invokeObjcSelf!(id, "initWithFileWrapper:", NSFileWrapper)(fileWrapper); + return result is this.objcObject ? this : (result !is null ? new NSTextAttachment(result) : null); + } + + this (NSFileWrapper fileWrapper) + { + super(NSTextAttachment.alloc.initWithFileWrapper(fileWrapper).objcObject); + } + + void setFileWrapper (NSFileWrapper fileWrapper) + { + return invokeObjcSelf!(void, "setFileWrapper:", NSFileWrapper)(fileWrapper); + } + + NSFileWrapper fileWrapper () + { + return invokeObjcSelf!(NSFileWrapper, "fileWrapper"); + } + + INSTextAttachmentCell attachmentCell () + { + return invokeObjcSelf!(INSTextAttachmentCell, "attachmentCell"); + } + + void setAttachmentCell (INSTextAttachmentCell cell) + { + return invokeObjcSelf!(void, "setAttachmentCell:", INSTextAttachmentCell)(cell); + } + +} + +interface INSTextAttachmentCell : INSObject +{ + void drawWithFrame (NSRect cellFrame, NSView controlView); + bool wantsToTrackMouse (); + void highlight (bool flag, NSRect cellFrame, NSView controlView); + bool trackMouse (NSEvent theEvent, NSRect cellFrame, NSView controlView, bool flag); + NSSize cellSize (); + NSPoint cellBaselineOffset (); + void setAttachment (NSTextAttachment anObject); + NSTextAttachment attachment (); + void drawWithFrame (NSRect cellFrame, NSView controlView, NSUInteger charIndex); + void drawWithFrame (NSRect cellFrame, NSView controlView, NSUInteger charIndex, NSLayoutManager layoutManager); + bool wantsToTrackMouseForEvent (NSEvent theEvent, NSRect cellFrame, NSView controlView, NSUInteger charIndex); + bool trackMouse (NSEvent theEvent, NSRect cellFrame, NSView controlView, NSUInteger charIndex, bool flag); + NSRect cellFrameForTextContainer (NSTextContainer textContainer, NSRect lineFrag, NSPoint position, NSUInteger charIndex); +} + +const TNSMutableAttributedStringAttachmentConveniences = ` + + void updateAttachmentsFromPath (NSString path) + { + return invokeObjcSelf!(void, "updateAttachmentsFromPath:", NSString)(path); + } + + //mixin ObjcBindMethod!(updateAttachmentsFromPath, "updateAttachmentsFromPath:"); + +`; + +const TNSAttributedStringAttachmentConveniences = ` + + static NSAttributedString attributedStringWithAttachment (NSTextAttachment attachment) + { + return invokeObjcSelfClass!(NSAttributedString, "attributedStringWithAttachment:", NSTextAttachment)(attachment); + } + + //mixin ObjcBindClassMethod!(attributedStringWithAttachment, "attributedStringWithAttachment:"); + +`; +