Mercurial > projects > dstep
comparison dstep/appkit/NSHelpManager.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.NSHelpManager; | |
8 | |
9 import dstep.appkit.AppKitDefines; | |
10 import dstep.appkit.NSApplication; | |
11 import dstep.appkit.NSAttributedString; | |
12 import dstep.appkit.NSWindow; | |
13 import dstep.foundation.NSAttributedString; | |
14 import dstep.foundation.NSBundle; | |
15 import dstep.foundation.NSGeometry; | |
16 import dstep.foundation.NSMapTable; | |
17 import dstep.foundation.NSObject; | |
18 import dstep.foundation.NSString; | |
19 import dstep.objc.bridge.Bridge; | |
20 import dstep.objc.objc; | |
21 | |
22 import bindings = dstep.appkit.NSHelpManager_bindings; | |
23 | |
24 private | |
25 { | |
26 NSString NSContextHelpModeDidActivateNotification_; | |
27 NSString NSContextHelpModeDidDeactivateNotification_; | |
28 } | |
29 | |
30 NSString NSContextHelpModeDidActivateNotification () | |
31 { | |
32 if (NSContextHelpModeDidActivateNotification_) | |
33 return NSContextHelpModeDidActivateNotification_; | |
34 | |
35 return NSContextHelpModeDidActivateNotification_ = new NSString(bindings.NSContextHelpModeDidActivateNotification); | |
36 } | |
37 | |
38 NSString NSContextHelpModeDidDeactivateNotification () | |
39 { | |
40 if (NSContextHelpModeDidDeactivateNotification_) | |
41 return NSContextHelpModeDidDeactivateNotification_; | |
42 | |
43 return NSContextHelpModeDidDeactivateNotification_ = new NSString(bindings.NSContextHelpModeDidDeactivateNotification); | |
44 } | |
45 | |
46 class NSHelpManager : NSObject | |
47 { | |
48 mixin (ObjcWrap); | |
49 | |
50 static NSHelpManager sharedHelpManager () | |
51 { | |
52 return invokeObjcSelfClass!(NSHelpManager, "sharedHelpManager"); | |
53 } | |
54 | |
55 static void setContextHelpModeActive (bool active) | |
56 { | |
57 return invokeObjcSelfClass!(void, "setContextHelpModeActive:", bool)(active); | |
58 } | |
59 | |
60 static bool isContextHelpModeActive () | |
61 { | |
62 return invokeObjcSelfClass!(bool, "isContextHelpModeActive"); | |
63 } | |
64 | |
65 void setContextHelp (NSAttributedString attrString, Object object) | |
66 { | |
67 return invokeObjcSelf!(void, "setContextHelp:forObject:", NSAttributedString, Object)(attrString, object); | |
68 } | |
69 | |
70 void removeContextHelpForObject (Object object) | |
71 { | |
72 return invokeObjcSelf!(void, "removeContextHelpForObject:", Object)(object); | |
73 } | |
74 | |
75 NSAttributedString contextHelpForObject (Object object) | |
76 { | |
77 return invokeObjcSelf!(NSAttributedString, "contextHelpForObject:", Object)(object); | |
78 } | |
79 | |
80 bool showContextHelpForObject (Object object, NSPoint pt) | |
81 { | |
82 return invokeObjcSelf!(bool, "showContextHelpForObject:locationHint:", Object, NSPoint)(object, pt); | |
83 } | |
84 | |
85 void openHelpAnchor (NSString anchor, NSString book) | |
86 { | |
87 return invokeObjcSelf!(void, "openHelpAnchor:inBook:", NSString, NSString)(anchor, book); | |
88 } | |
89 | |
90 void findString (NSString query, NSString book) | |
91 { | |
92 return invokeObjcSelf!(void, "findString:inBook:", NSString, NSString)(query, book); | |
93 } | |
94 } | |
95 | |
96 const TNSApplicationHelpExtension = ` | |
97 | |
98 void activateContextHelpMode (Object sender) | |
99 { | |
100 return invokeObjcSelf!(void, "activateContextHelpMode:", Object)(sender); | |
101 } | |
102 | |
103 void showHelp (Object sender) | |
104 { | |
105 return invokeObjcSelf!(void, "showHelp:", Object)(sender); | |
106 } | |
107 | |
108 //mixin ObjcBindMethod!(activateContextHelpMode, "activateContextHelpMode:"); | |
109 //mixin ObjcBindMethod!(showHelp, "showHelp:"); | |
110 | |
111 `; | |
112 | |
113 const TNSBundleHelpExtension = ` | |
114 | |
115 NSAttributedString contextHelpForKey (NSString key) | |
116 { | |
117 return invokeObjcSelf!(NSAttributedString, "contextHelpForKey:", NSString)(key); | |
118 } | |
119 | |
120 //mixin ObjcBindMethod!(contextHelpForKey, "contextHelpForKey:"); | |
121 | |
122 `; | |
123 |