comparison dstep/appkit/NSObjectController.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.NSObjectController;
8
9 import dstep.appkit.NSController;
10 import dstep.appkit.NSMenu;
11 import dstep.appkit.NSUserInterfaceValidation;
12 import dstep.coredata.NSFetchRequest;
13 import dstep.coredata.NSManagedObjectContext;
14 import dstep.foundation.NSArray;
15 import dstep.foundation.NSError;
16 import dstep.foundation.NSPredicate;
17 import dstep.foundation.NSString;
18 import dstep.objc.bridge.Bridge;
19 import dstep.objc.objc;
20
21 const TNSManagedController = `
22
23 NSManagedObjectContext managedObjectContext ()
24 {
25 return invokeObjcSelf!(NSManagedObjectContext, "managedObjectContext");
26 }
27
28 void setManagedObjectContext (NSManagedObjectContext managedObjectContext)
29 {
30 return invokeObjcSelf!(void, "setManagedObjectContext:", NSManagedObjectContext)(managedObjectContext);
31 }
32
33 NSString entityName ()
34 {
35 return invokeObjcSelf!(NSString, "entityName");
36 }
37
38 void setEntityName (NSString entityName)
39 {
40 return invokeObjcSelf!(void, "setEntityName:", NSString)(entityName);
41 }
42
43 NSPredicate fetchPredicate ()
44 {
45 return invokeObjcSelf!(NSPredicate, "fetchPredicate");
46 }
47
48 void setFetchPredicate (NSPredicate predicate)
49 {
50 return invokeObjcSelf!(void, "setFetchPredicate:", NSPredicate)(predicate);
51 }
52
53 bool fetchWithRequest (NSFetchRequest fetchRequest, bool merge, NSError** error)
54 {
55 return invokeObjcSelf!(bool, "fetchWithRequest:merge:error:", NSFetchRequest, bool, NSError**)(fetchRequest, merge, error);
56 }
57
58 void fetch (Object sender)
59 {
60 return invokeObjcSelf!(void, "fetch:", Object)(sender);
61 }
62
63 void setUsesLazyFetching (bool enabled)
64 {
65 return invokeObjcSelf!(void, "setUsesLazyFetching:", bool)(enabled);
66 }
67
68 bool usesLazyFetching ()
69 {
70 return invokeObjcSelf!(bool, "usesLazyFetching");
71 }
72
73 NSFetchRequest defaultFetchRequest ()
74 {
75 return invokeObjcSelf!(NSFetchRequest, "defaultFetchRequest");
76 }
77
78 //mixin ObjcBindMethod!(managedObjectContext, "managedObjectContext");
79 //mixin ObjcBindMethod!(setManagedObjectContext, "setManagedObjectContext:");
80 //mixin ObjcBindMethod!(entityName, "entityName");
81 //mixin ObjcBindMethod!(setEntityName, "setEntityName:");
82 //mixin ObjcBindMethod!(fetchPredicate, "fetchPredicate");
83 //mixin ObjcBindMethod!(setFetchPredicate, "setFetchPredicate:");
84 //mixin ObjcBindMethod!(fetchWithRequest, "fetchWithRequest:merge:error:");
85 //mixin ObjcBindMethod!(fetch, "fetch:");
86 //mixin ObjcBindMethod!(setUsesLazyFetching, "setUsesLazyFetching:");
87 //mixin ObjcBindMethod!(usesLazyFetching, "usesLazyFetching");
88 //mixin ObjcBindMethod!(defaultFetchRequest, "defaultFetchRequest");
89
90 `;
91
92 class NSObjectController : NSController
93 {
94 mixin (ObjcWrap);
95
96 NSObjectController initWithContent (Object content)
97 {
98 id result = invokeObjcSelf!(id, "initWithContent:", Object)(content);
99 return result is this.objcObject ? this : (result !is null ? new NSObjectController(result) : null);
100 }
101
102 this (Object content)
103 {
104 super(NSObjectController.alloc.initWithContent(content).objcObject);
105 }
106
107 void setContent (Object content)
108 {
109 return invokeObjcSelf!(void, "setContent:", Object)(content);
110 }
111
112 Object content ()
113 {
114 return invokeObjcSelf!(Object, "content");
115 }
116
117 Object selection ()
118 {
119 return invokeObjcSelf!(Object, "selection");
120 }
121
122 NSArray selectedObjects ()
123 {
124 return invokeObjcSelf!(NSArray, "selectedObjects");
125 }
126
127 void setAutomaticallyPreparesContent (bool flag)
128 {
129 return invokeObjcSelf!(void, "setAutomaticallyPreparesContent:", bool)(flag);
130 }
131
132 bool automaticallyPreparesContent ()
133 {
134 return invokeObjcSelf!(bool, "automaticallyPreparesContent");
135 }
136
137 void prepareContent ()
138 {
139 return invokeObjcSelf!(void, "prepareContent");
140 }
141
142 void setObjectClass (Class objectClass)
143 {
144 return invokeObjcSelf!(void, "setObjectClass:", Class)(objectClass);
145 }
146
147 Class objectClass ()
148 {
149 return invokeObjcSelf!(Class, "objectClass");
150 }
151
152 Object newObject ()
153 {
154 return invokeObjcSelf!(Object, "newObject");
155 }
156
157 void addObject (Object object)
158 {
159 return invokeObjcSelf!(void, "addObject:", Object)(object);
160 }
161
162 void removeObject (Object object)
163 {
164 return invokeObjcSelf!(void, "removeObject:", Object)(object);
165 }
166
167 void setEditable (bool flag)
168 {
169 return invokeObjcSelf!(void, "setEditable:", bool)(flag);
170 }
171
172 bool isEditable ()
173 {
174 return invokeObjcSelf!(bool, "isEditable");
175 }
176
177 void add (Object sender)
178 {
179 return invokeObjcSelf!(void, "add:", Object)(sender);
180 }
181
182 bool canAdd ()
183 {
184 return invokeObjcSelf!(bool, "canAdd");
185 }
186
187 void remove (Object sender)
188 {
189 return invokeObjcSelf!(void, "remove:", Object)(sender);
190 }
191
192 bool canRemove ()
193 {
194 return invokeObjcSelf!(bool, "canRemove");
195 }
196
197 bool validateUserInterfaceItem (INSValidatedUserInterfaceItem item)
198 {
199 return invokeObjcSelf!(bool, "validateUserInterfaceItem:", INSValidatedUserInterfaceItem)(item);
200 }
201
202 // NSManagedController
203 NSManagedObjectContext managedObjectContext ()
204 {
205 return invokeObjcSelf!(NSManagedObjectContext, "managedObjectContext");
206 }
207
208 void setManagedObjectContext (NSManagedObjectContext managedObjectContext)
209 {
210 return invokeObjcSelf!(void, "setManagedObjectContext:", NSManagedObjectContext)(managedObjectContext);
211 }
212
213 NSString entityName ()
214 {
215 return invokeObjcSelf!(NSString, "entityName");
216 }
217
218 void setEntityName (NSString entityName)
219 {
220 return invokeObjcSelf!(void, "setEntityName:", NSString)(entityName);
221 }
222
223 NSPredicate fetchPredicate ()
224 {
225 return invokeObjcSelf!(NSPredicate, "fetchPredicate");
226 }
227
228 void setFetchPredicate (NSPredicate predicate)
229 {
230 return invokeObjcSelf!(void, "setFetchPredicate:", NSPredicate)(predicate);
231 }
232
233 bool fetchWithRequest (NSFetchRequest fetchRequest, bool merge, NSError** error)
234 {
235 return invokeObjcSelf!(bool, "fetchWithRequest:merge:error:", NSFetchRequest, bool, NSError**)(fetchRequest, merge, error);
236 }
237
238 void fetch (Object sender)
239 {
240 return invokeObjcSelf!(void, "fetch:", Object)(sender);
241 }
242
243 void setUsesLazyFetching (bool enabled)
244 {
245 return invokeObjcSelf!(void, "setUsesLazyFetching:", bool)(enabled);
246 }
247
248 bool usesLazyFetching ()
249 {
250 return invokeObjcSelf!(bool, "usesLazyFetching");
251 }
252
253 NSFetchRequest defaultFetchRequest ()
254 {
255 return invokeObjcSelf!(NSFetchRequest, "defaultFetchRequest");
256 }
257 }