Mercurial > projects > dstep
comparison dstep/appkit/NSAlert.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.NSAlert; | |
8 | |
9 import dstep.appkit.NSButton; | |
10 import dstep.appkit.NSGraphics; | |
11 import dstep.appkit.NSImage; | |
12 import dstep.appkit.NSPanel; | |
13 import dstep.appkit.NSTextField; | |
14 import dstep.appkit.NSView; | |
15 import dstep.appkit.NSWindow; | |
16 import dstep.foundation.NSArray; | |
17 import dstep.foundation.NSError; | |
18 import dstep.foundation.NSObjCRuntime; | |
19 import dstep.foundation.NSObject; | |
20 import dstep.foundation.NSString; | |
21 import dstep.objc.bridge.Bridge; | |
22 import dstep.objc.objc; | |
23 | |
24 alias NSUInteger NSAlertStyle; | |
25 | |
26 enum | |
27 { | |
28 NSWarningAlertStyle = 0, | |
29 NSInformationalAlertStyle = 1, | |
30 NSCriticalAlertStyle = 2 | |
31 } | |
32 | |
33 enum | |
34 { | |
35 NSAlertFirstButtonReturn = 1000, | |
36 NSAlertSecondButtonReturn = 1001, | |
37 NSAlertThirdButtonReturn = 1002 | |
38 } | |
39 | |
40 class NSAlert : NSObject | |
41 { | |
42 mixin (ObjcWrap); | |
43 | |
44 static NSAlert alertWithError (NSError error) | |
45 { | |
46 return invokeObjcSelfClass!(NSAlert, "alertWithError:", NSError)(error); | |
47 } | |
48 | |
49 static NSAlert alertWithMessageText (NSString message, NSString defaultButton, NSString alternateButton, NSString otherButton, NSString informativeTextWithFormat, ...) | |
50 { | |
51 return invokeObjcSelfClass!(NSAlert, "alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat:", NSString, NSString, NSString, NSString, NSString)(message, defaultButton, alternateButton, otherButton, informativeTextWithFormat); | |
52 } | |
53 | |
54 void setMessageText (NSString messageText) | |
55 { | |
56 return invokeObjcSelf!(void, "setMessageText:", NSString)(messageText); | |
57 } | |
58 | |
59 void setInformativeText (NSString informativeText) | |
60 { | |
61 return invokeObjcSelf!(void, "setInformativeText:", NSString)(informativeText); | |
62 } | |
63 | |
64 NSString messageText () | |
65 { | |
66 return invokeObjcSelf!(NSString, "messageText"); | |
67 } | |
68 | |
69 NSString informativeText () | |
70 { | |
71 return invokeObjcSelf!(NSString, "informativeText"); | |
72 } | |
73 | |
74 void setIcon (NSImage icon) | |
75 { | |
76 return invokeObjcSelf!(void, "setIcon:", NSImage)(icon); | |
77 } | |
78 | |
79 NSImage icon () | |
80 { | |
81 return invokeObjcSelf!(NSImage, "icon"); | |
82 } | |
83 | |
84 NSButton addButtonWithTitle (NSString title) | |
85 { | |
86 return invokeObjcSelf!(NSButton, "addButtonWithTitle:", NSString)(title); | |
87 } | |
88 | |
89 NSArray buttons () | |
90 { | |
91 return invokeObjcSelf!(NSArray, "buttons"); | |
92 } | |
93 | |
94 void setShowsHelp (bool showsHelp) | |
95 { | |
96 return invokeObjcSelf!(void, "setShowsHelp:", bool)(showsHelp); | |
97 } | |
98 | |
99 bool showsHelp () | |
100 { | |
101 return invokeObjcSelf!(bool, "showsHelp"); | |
102 } | |
103 | |
104 void setHelpAnchor (NSString anchor) | |
105 { | |
106 return invokeObjcSelf!(void, "setHelpAnchor:", NSString)(anchor); | |
107 } | |
108 | |
109 NSString helpAnchor () | |
110 { | |
111 return invokeObjcSelf!(NSString, "helpAnchor"); | |
112 } | |
113 | |
114 void setAlertStyle (uint style) | |
115 { | |
116 return invokeObjcSelf!(void, "setAlertStyle:", uint)(style); | |
117 } | |
118 | |
119 uint alertStyle () | |
120 { | |
121 return invokeObjcSelf!(uint, "alertStyle"); | |
122 } | |
123 | |
124 void setDelegate (Object delegate_) | |
125 { | |
126 return invokeObjcSelf!(void, "setDelegate:", Object)(delegate_); | |
127 } | |
128 | |
129 Object delegate_ () | |
130 { | |
131 return invokeObjcSelf!(Object, "delegate"); | |
132 } | |
133 | |
134 void setShowsSuppressionButton (bool flag) | |
135 { | |
136 return invokeObjcSelf!(void, "setShowsSuppressionButton:", bool)(flag); | |
137 } | |
138 | |
139 bool showsSuppressionButton () | |
140 { | |
141 return invokeObjcSelf!(bool, "showsSuppressionButton"); | |
142 } | |
143 | |
144 NSButton suppressionButton () | |
145 { | |
146 return invokeObjcSelf!(NSButton, "suppressionButton"); | |
147 } | |
148 | |
149 void setAccessoryView (NSView view) | |
150 { | |
151 return invokeObjcSelf!(void, "setAccessoryView:", NSView)(view); | |
152 } | |
153 | |
154 NSView accessoryView () | |
155 { | |
156 return invokeObjcSelf!(NSView, "accessoryView"); | |
157 } | |
158 | |
159 void layout () | |
160 { | |
161 return invokeObjcSelf!(void, "layout"); | |
162 } | |
163 | |
164 NSInteger runModal () | |
165 { | |
166 return invokeObjcSelf!(NSInteger, "runModal"); | |
167 } | |
168 | |
169 void beginSheetModalForWindow (NSWindow window, Object delegate_, SEL didEndSelector, void* contextInfo) | |
170 { | |
171 return invokeObjcSelf!(void, "beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:", NSWindow, Object, SEL, void*)(window, delegate_, didEndSelector, contextInfo); | |
172 } | |
173 | |
174 Object window () | |
175 { | |
176 return invokeObjcSelf!(Object, "window"); | |
177 } | |
178 } | |
179 | |
180 const TNSAlertDelegate = ` | |
181 | |
182 bool alertShowHelp (NSAlert alert) | |
183 { | |
184 return invokeObjcSelf!(bool, "alertShowHelp:", NSAlert)(alert); | |
185 } | |
186 | |
187 //mixin ObjcBindMethod!(alertShowHelp, "alertShowHelp:"); | |
188 | |
189 `; | |
190 |