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