Mercurial > projects > dstep
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dstep/appkit/NSObjectController.d Sun Jan 03 22:06:11 2010 +0100 @@ -0,0 +1,257 @@ +/** + * Copyright: Copyright (c) 2009 Jacob Carlborg. + * Authors: Jacob Carlborg + * Version: Initial created: Sep 24, 2009 + * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) + */ +module dstep.appkit.NSObjectController; + +import dstep.appkit.NSController; +import dstep.appkit.NSMenu; +import dstep.appkit.NSUserInterfaceValidation; +import dstep.coredata.NSFetchRequest; +import dstep.coredata.NSManagedObjectContext; +import dstep.foundation.NSArray; +import dstep.foundation.NSError; +import dstep.foundation.NSPredicate; +import dstep.foundation.NSString; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc; + +const TNSManagedController = ` + + NSManagedObjectContext managedObjectContext () + { + return invokeObjcSelf!(NSManagedObjectContext, "managedObjectContext"); + } + + void setManagedObjectContext (NSManagedObjectContext managedObjectContext) + { + return invokeObjcSelf!(void, "setManagedObjectContext:", NSManagedObjectContext)(managedObjectContext); + } + + NSString entityName () + { + return invokeObjcSelf!(NSString, "entityName"); + } + + void setEntityName (NSString entityName) + { + return invokeObjcSelf!(void, "setEntityName:", NSString)(entityName); + } + + NSPredicate fetchPredicate () + { + return invokeObjcSelf!(NSPredicate, "fetchPredicate"); + } + + void setFetchPredicate (NSPredicate predicate) + { + return invokeObjcSelf!(void, "setFetchPredicate:", NSPredicate)(predicate); + } + + bool fetchWithRequest (NSFetchRequest fetchRequest, bool merge, NSError** error) + { + return invokeObjcSelf!(bool, "fetchWithRequest:merge:error:", NSFetchRequest, bool, NSError**)(fetchRequest, merge, error); + } + + void fetch (Object sender) + { + return invokeObjcSelf!(void, "fetch:", Object)(sender); + } + + void setUsesLazyFetching (bool enabled) + { + return invokeObjcSelf!(void, "setUsesLazyFetching:", bool)(enabled); + } + + bool usesLazyFetching () + { + return invokeObjcSelf!(bool, "usesLazyFetching"); + } + + NSFetchRequest defaultFetchRequest () + { + return invokeObjcSelf!(NSFetchRequest, "defaultFetchRequest"); + } + + //mixin ObjcBindMethod!(managedObjectContext, "managedObjectContext"); + //mixin ObjcBindMethod!(setManagedObjectContext, "setManagedObjectContext:"); + //mixin ObjcBindMethod!(entityName, "entityName"); + //mixin ObjcBindMethod!(setEntityName, "setEntityName:"); + //mixin ObjcBindMethod!(fetchPredicate, "fetchPredicate"); + //mixin ObjcBindMethod!(setFetchPredicate, "setFetchPredicate:"); + //mixin ObjcBindMethod!(fetchWithRequest, "fetchWithRequest:merge:error:"); + //mixin ObjcBindMethod!(fetch, "fetch:"); + //mixin ObjcBindMethod!(setUsesLazyFetching, "setUsesLazyFetching:"); + //mixin ObjcBindMethod!(usesLazyFetching, "usesLazyFetching"); + //mixin ObjcBindMethod!(defaultFetchRequest, "defaultFetchRequest"); + +`; + +class NSObjectController : NSController +{ + mixin (ObjcWrap); + + NSObjectController initWithContent (Object content) + { + id result = invokeObjcSelf!(id, "initWithContent:", Object)(content); + return result is this.objcObject ? this : (result !is null ? new NSObjectController(result) : null); + } + + this (Object content) + { + super(NSObjectController.alloc.initWithContent(content).objcObject); + } + + void setContent (Object content) + { + return invokeObjcSelf!(void, "setContent:", Object)(content); + } + + Object content () + { + return invokeObjcSelf!(Object, "content"); + } + + Object selection () + { + return invokeObjcSelf!(Object, "selection"); + } + + NSArray selectedObjects () + { + return invokeObjcSelf!(NSArray, "selectedObjects"); + } + + void setAutomaticallyPreparesContent (bool flag) + { + return invokeObjcSelf!(void, "setAutomaticallyPreparesContent:", bool)(flag); + } + + bool automaticallyPreparesContent () + { + return invokeObjcSelf!(bool, "automaticallyPreparesContent"); + } + + void prepareContent () + { + return invokeObjcSelf!(void, "prepareContent"); + } + + void setObjectClass (Class objectClass) + { + return invokeObjcSelf!(void, "setObjectClass:", Class)(objectClass); + } + + Class objectClass () + { + return invokeObjcSelf!(Class, "objectClass"); + } + + Object newObject () + { + return invokeObjcSelf!(Object, "newObject"); + } + + void addObject (Object object) + { + return invokeObjcSelf!(void, "addObject:", Object)(object); + } + + void removeObject (Object object) + { + return invokeObjcSelf!(void, "removeObject:", Object)(object); + } + + void setEditable (bool flag) + { + return invokeObjcSelf!(void, "setEditable:", bool)(flag); + } + + bool isEditable () + { + return invokeObjcSelf!(bool, "isEditable"); + } + + void add (Object sender) + { + return invokeObjcSelf!(void, "add:", Object)(sender); + } + + bool canAdd () + { + return invokeObjcSelf!(bool, "canAdd"); + } + + void remove (Object sender) + { + return invokeObjcSelf!(void, "remove:", Object)(sender); + } + + bool canRemove () + { + return invokeObjcSelf!(bool, "canRemove"); + } + + bool validateUserInterfaceItem (INSValidatedUserInterfaceItem item) + { + return invokeObjcSelf!(bool, "validateUserInterfaceItem:", INSValidatedUserInterfaceItem)(item); + } + + // NSManagedController + NSManagedObjectContext managedObjectContext () + { + return invokeObjcSelf!(NSManagedObjectContext, "managedObjectContext"); + } + + void setManagedObjectContext (NSManagedObjectContext managedObjectContext) + { + return invokeObjcSelf!(void, "setManagedObjectContext:", NSManagedObjectContext)(managedObjectContext); + } + + NSString entityName () + { + return invokeObjcSelf!(NSString, "entityName"); + } + + void setEntityName (NSString entityName) + { + return invokeObjcSelf!(void, "setEntityName:", NSString)(entityName); + } + + NSPredicate fetchPredicate () + { + return invokeObjcSelf!(NSPredicate, "fetchPredicate"); + } + + void setFetchPredicate (NSPredicate predicate) + { + return invokeObjcSelf!(void, "setFetchPredicate:", NSPredicate)(predicate); + } + + bool fetchWithRequest (NSFetchRequest fetchRequest, bool merge, NSError** error) + { + return invokeObjcSelf!(bool, "fetchWithRequest:merge:error:", NSFetchRequest, bool, NSError**)(fetchRequest, merge, error); + } + + void fetch (Object sender) + { + return invokeObjcSelf!(void, "fetch:", Object)(sender); + } + + void setUsesLazyFetching (bool enabled) + { + return invokeObjcSelf!(void, "setUsesLazyFetching:", bool)(enabled); + } + + bool usesLazyFetching () + { + return invokeObjcSelf!(bool, "usesLazyFetching"); + } + + NSFetchRequest defaultFetchRequest () + { + return invokeObjcSelf!(NSFetchRequest, "defaultFetchRequest"); + } +} \ No newline at end of file