comparison dstep/appkit/NSDrawer.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.NSDrawer;
8
9 import dstep.appkit.AppKitDefines;
10 import dstep.appkit.NSResponder;
11 import dstep.appkit.NSView;
12 import dstep.appkit.NSWindow;
13 import dstep.applicationservices.coregraphics.CGBase;
14 import dstep.corefoundation.CFDate;
15 import dstep.corefoundation.CFRunLoop;
16 import dstep.foundation.NSArray;
17 import dstep.foundation.NSGeometry;
18 import dstep.foundation.NSLock;
19 import dstep.foundation.NSNotification;
20 import dstep.foundation.NSObjCRuntime;
21 import dstep.foundation.NSObject;
22 import dstep.foundation.NSString;
23 import dstep.objc.bridge.Bridge;
24 import dstep.objc.objc;
25
26 import bindings = dstep.appkit.NSDrawer_bindings;
27
28 alias NSUInteger NSDrawerState;
29
30 private
31 {
32 NSString NSDrawerWillOpenNotification_;
33 NSString NSDrawerDidOpenNotification_;
34 NSString NSDrawerWillCloseNotification_;
35 NSString NSDrawerDidCloseNotification_;
36 }
37
38 NSString NSDrawerWillOpenNotification ()
39 {
40 if (NSDrawerWillOpenNotification_)
41 return NSDrawerWillOpenNotification_;
42
43 return NSDrawerWillOpenNotification_ = new NSString(bindings.NSDrawerWillOpenNotification);
44 }
45
46 NSString NSDrawerDidOpenNotification ()
47 {
48 if (NSDrawerDidOpenNotification_)
49 return NSDrawerDidOpenNotification_;
50
51 return NSDrawerDidOpenNotification_ = new NSString(bindings.NSDrawerDidOpenNotification);
52 }
53
54 NSString NSDrawerWillCloseNotification ()
55 {
56 if (NSDrawerWillCloseNotification_)
57 return NSDrawerWillCloseNotification_;
58
59 return NSDrawerWillCloseNotification_ = new NSString(bindings.NSDrawerWillCloseNotification);
60 }
61
62 NSString NSDrawerDidCloseNotification ()
63 {
64 if (NSDrawerDidCloseNotification_)
65 return NSDrawerDidCloseNotification_;
66
67 return NSDrawerDidCloseNotification_ = new NSString(bindings.NSDrawerDidCloseNotification);
68 }
69
70 enum
71 {
72 NSDrawerClosedState = 0,
73 NSDrawerOpeningState = 1,
74 NSDrawerOpenState = 2,
75 NSDrawerClosingState = 3
76 }
77
78 class NSDrawer : NSResponder
79 {
80 mixin (ObjcWrap);
81
82 NSDrawer initWithContentSize (NSSize contentSize, int edge)
83 {
84 id result = invokeObjcSelf!(id, "initWithContentSize:preferredEdge:", NSSize, int)(contentSize, edge);
85 return result is this.objcObject ? this : (result !is null ? new NSDrawer(result) : null);
86 }
87
88 this (NSSize contentSize, int edge)
89 {
90 super(NSDrawer.alloc.initWithContentSize(contentSize, edge).objcObject);
91 }
92
93 void setParentWindow (NSWindow parent)
94 {
95 return invokeObjcSelf!(void, "setParentWindow:", NSWindow)(parent);
96 }
97
98 NSWindow parentWindow ()
99 {
100 return invokeObjcSelf!(NSWindow, "parentWindow");
101 }
102
103 void setContentView (NSView aView)
104 {
105 return invokeObjcSelf!(void, "setContentView:", NSView)(aView);
106 }
107
108 NSView contentView ()
109 {
110 return invokeObjcSelf!(NSView, "contentView");
111 }
112
113 void setPreferredEdge (int edge)
114 {
115 return invokeObjcSelf!(void, "setPreferredEdge:", int)(edge);
116 }
117
118 int preferredEdge ()
119 {
120 return invokeObjcSelf!(int, "preferredEdge");
121 }
122
123 void setDelegate (Object anObject)
124 {
125 return invokeObjcSelf!(void, "setDelegate:", Object)(anObject);
126 }
127
128 Object delegate_ ()
129 {
130 return invokeObjcSelf!(Object, "delegate");
131 }
132
133 void open ()
134 {
135 return invokeObjcSelf!(void, "open");
136 }
137
138 void openOnEdge (int edge)
139 {
140 return invokeObjcSelf!(void, "openOnEdge:", int)(edge);
141 }
142
143 void close ()
144 {
145 return invokeObjcSelf!(void, "close");
146 }
147
148 void open (Object sender)
149 {
150 return invokeObjcSelf!(void, "open:", Object)(sender);
151 }
152
153 void close (Object sender)
154 {
155 return invokeObjcSelf!(void, "close:", Object)(sender);
156 }
157
158 void toggle (Object sender)
159 {
160 return invokeObjcSelf!(void, "toggle:", Object)(sender);
161 }
162
163 NSInteger state ()
164 {
165 return invokeObjcSelf!(NSInteger, "state");
166 }
167
168 int edge ()
169 {
170 return invokeObjcSelf!(int, "edge");
171 }
172
173 void setContentSize (NSSize size)
174 {
175 return invokeObjcSelf!(void, "setContentSize:", NSSize)(size);
176 }
177
178 NSSize contentSize ()
179 {
180 return invokeObjcSelf!(NSSize, "contentSize");
181 }
182
183 void setMinContentSize (NSSize size)
184 {
185 return invokeObjcSelf!(void, "setMinContentSize:", NSSize)(size);
186 }
187
188 NSSize minContentSize ()
189 {
190 return invokeObjcSelf!(NSSize, "minContentSize");
191 }
192
193 void setMaxContentSize (NSSize size)
194 {
195 return invokeObjcSelf!(void, "setMaxContentSize:", NSSize)(size);
196 }
197
198 NSSize maxContentSize ()
199 {
200 return invokeObjcSelf!(NSSize, "maxContentSize");
201 }
202
203 void setLeadingOffset (CGFloat offset)
204 {
205 return invokeObjcSelf!(void, "setLeadingOffset:", CGFloat)(offset);
206 }
207
208 CGFloat leadingOffset ()
209 {
210 return invokeObjcSelf!(CGFloat, "leadingOffset");
211 }
212
213 void setTrailingOffset (CGFloat offset)
214 {
215 return invokeObjcSelf!(void, "setTrailingOffset:", CGFloat)(offset);
216 }
217
218 CGFloat trailingOffset ()
219 {
220 return invokeObjcSelf!(CGFloat, "trailingOffset");
221 }
222 }
223
224 const TDrawers = `
225
226 NSArray drawers ()
227 {
228 return invokeObjcSelf!(NSArray, "drawers");
229 }
230
231 //mixin ObjcBindMethod!(drawers, "drawers");
232
233 `;
234
235 const TNSDrawerDelegate = `
236
237 bool drawerShouldOpen (NSDrawer sender)
238 {
239 return invokeObjcSelf!(bool, "drawerShouldOpen:", NSDrawer)(sender);
240 }
241
242 bool drawerShouldClose (NSDrawer sender)
243 {
244 return invokeObjcSelf!(bool, "drawerShouldClose:", NSDrawer)(sender);
245 }
246
247 NSSize drawerWillResizeContents (NSDrawer sender, NSSize contentSize)
248 {
249 return invokeObjcSelf!(NSSize, "drawerWillResizeContents:toSize:", NSDrawer, NSSize)(sender, contentSize);
250 }
251
252 //mixin ObjcBindMethod!(drawerShouldOpen, "drawerShouldOpen:");
253 //mixin ObjcBindMethod!(drawerShouldClose, "drawerShouldClose:");
254 //mixin ObjcBindMethod!(drawerWillResizeContents, "drawerWillResizeContents:toSize:");
255
256 `;
257
258 const TNSDrawerNotifications = `
259
260 void drawerWillOpen (NSNotification notification)
261 {
262 return invokeObjcSelf!(void, "drawerWillOpen:", NSNotification)(notification);
263 }
264
265 void drawerDidOpen (NSNotification notification)
266 {
267 return invokeObjcSelf!(void, "drawerDidOpen:", NSNotification)(notification);
268 }
269
270 void drawerWillClose (NSNotification notification)
271 {
272 return invokeObjcSelf!(void, "drawerWillClose:", NSNotification)(notification);
273 }
274
275 void drawerDidClose (NSNotification notification)
276 {
277 return invokeObjcSelf!(void, "drawerDidClose:", NSNotification)(notification);
278 }
279
280 //mixin ObjcBindMethod!(drawerWillOpen, "drawerWillOpen:");
281 //mixin ObjcBindMethod!(drawerDidOpen, "drawerDidOpen:");
282 //mixin ObjcBindMethod!(drawerWillClose, "drawerWillClose:");
283 //mixin ObjcBindMethod!(drawerDidClose, "drawerDidClose:");
284
285 `;
286