Mercurial > projects > dstep
comparison 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 |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Sep 24, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.appkit.NSTextAttachment; | |
8 | |
9 import dstep.appkit.NSAttributedString; | |
10 import dstep.appkit.NSCell; | |
11 import dstep.appkit.NSEvent; | |
12 import dstep.appkit.NSFileWrapper; | |
13 import dstep.appkit.NSLayoutManager; | |
14 import dstep.appkit.NSTextContainer; | |
15 import dstep.appkit.NSView; | |
16 import dstep.foundation.NSCoder; | |
17 import dstep.foundation.NSGeometry; | |
18 import dstep.foundation.NSObjCRuntime; | |
19 import dstep.foundation.NSObject; | |
20 import dstep.objc.bridge.Bridge; | |
21 import dstep.objc.objc; | |
22 | |
23 enum | |
24 { | |
25 NSAttachmentCharacter = 0xfffc | |
26 } | |
27 | |
28 class NSTextAttachment : NSObject, INSCoding | |
29 { | |
30 mixin (ObjcWrap); | |
31 | |
32 this (NSCoder aDecoder) | |
33 { | |
34 super(typeof(this).alloc.initWithCoder(aDecoder).objcObject); | |
35 } | |
36 | |
37 void encodeWithCoder (NSCoder aCoder) | |
38 { | |
39 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
40 } | |
41 | |
42 typeof(this) initWithCoder (NSCoder aDecoder) | |
43 { | |
44 return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder); | |
45 } | |
46 | |
47 NSTextAttachment initWithFileWrapper (NSFileWrapper fileWrapper) | |
48 { | |
49 id result = invokeObjcSelf!(id, "initWithFileWrapper:", NSFileWrapper)(fileWrapper); | |
50 return result is this.objcObject ? this : (result !is null ? new NSTextAttachment(result) : null); | |
51 } | |
52 | |
53 this (NSFileWrapper fileWrapper) | |
54 { | |
55 super(NSTextAttachment.alloc.initWithFileWrapper(fileWrapper).objcObject); | |
56 } | |
57 | |
58 void setFileWrapper (NSFileWrapper fileWrapper) | |
59 { | |
60 return invokeObjcSelf!(void, "setFileWrapper:", NSFileWrapper)(fileWrapper); | |
61 } | |
62 | |
63 NSFileWrapper fileWrapper () | |
64 { | |
65 return invokeObjcSelf!(NSFileWrapper, "fileWrapper"); | |
66 } | |
67 | |
68 INSTextAttachmentCell attachmentCell () | |
69 { | |
70 return invokeObjcSelf!(INSTextAttachmentCell, "attachmentCell"); | |
71 } | |
72 | |
73 void setAttachmentCell (INSTextAttachmentCell cell) | |
74 { | |
75 return invokeObjcSelf!(void, "setAttachmentCell:", INSTextAttachmentCell)(cell); | |
76 } | |
77 | |
78 } | |
79 | |
80 interface INSTextAttachmentCell : INSObject | |
81 { | |
82 void drawWithFrame (NSRect cellFrame, NSView controlView); | |
83 bool wantsToTrackMouse (); | |
84 void highlight (bool flag, NSRect cellFrame, NSView controlView); | |
85 bool trackMouse (NSEvent theEvent, NSRect cellFrame, NSView controlView, bool flag); | |
86 NSSize cellSize (); | |
87 NSPoint cellBaselineOffset (); | |
88 void setAttachment (NSTextAttachment anObject); | |
89 NSTextAttachment attachment (); | |
90 void drawWithFrame (NSRect cellFrame, NSView controlView, NSUInteger charIndex); | |
91 void drawWithFrame (NSRect cellFrame, NSView controlView, NSUInteger charIndex, NSLayoutManager layoutManager); | |
92 bool wantsToTrackMouseForEvent (NSEvent theEvent, NSRect cellFrame, NSView controlView, NSUInteger charIndex); | |
93 bool trackMouse (NSEvent theEvent, NSRect cellFrame, NSView controlView, NSUInteger charIndex, bool flag); | |
94 NSRect cellFrameForTextContainer (NSTextContainer textContainer, NSRect lineFrag, NSPoint position, NSUInteger charIndex); | |
95 } | |
96 | |
97 const TNSMutableAttributedStringAttachmentConveniences = ` | |
98 | |
99 void updateAttachmentsFromPath (NSString path) | |
100 { | |
101 return invokeObjcSelf!(void, "updateAttachmentsFromPath:", NSString)(path); | |
102 } | |
103 | |
104 //mixin ObjcBindMethod!(updateAttachmentsFromPath, "updateAttachmentsFromPath:"); | |
105 | |
106 `; | |
107 | |
108 const TNSAttributedStringAttachmentConveniences = ` | |
109 | |
110 static NSAttributedString attributedStringWithAttachment (NSTextAttachment attachment) | |
111 { | |
112 return invokeObjcSelfClass!(NSAttributedString, "attributedStringWithAttachment:", NSTextAttachment)(attachment); | |
113 } | |
114 | |
115 //mixin ObjcBindClassMethod!(attributedStringWithAttachment, "attributedStringWithAttachment:"); | |
116 | |
117 `; | |
118 |