From b239053810e9191edcd322f84bfcaf66bf732a07 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Thu, 22 Jan 2009 20:01:04 -0800 Subject: [PATCH] First take at CPController, CPObjectController. --- Foundation/CPController.j | 80 +++++ Foundation/CPObjectController.j | 500 ++++++++++++++++++++++++++++++++ 2 files changed, 580 insertions(+) create mode 100644 Foundation/CPController.j create mode 100644 Foundation/CPObjectController.j diff --git a/Foundation/CPController.j b/Foundation/CPController.j new file mode 100644 index 000000000..2271f60b7 --- /dev/null +++ b/Foundation/CPController.j @@ -0,0 +1,80 @@ +// +// CPController.j +// AppKit +// +// Created by Ross Boucher 1/15/09 +// Copyright 280 North +// +// Adapted from GNUStep +// Copyright (C) 2007 Free Software Foundation, Inc +// Released under the LGPL. +// + +var CPControllerDeclaredKeysKey = @"CPControllerDeclaredKeysKey"; + +@implementation CPController : CPObject +{ + CPArray _editors; + CPArray _declaredKeys; +} + +- (id)init +{ + self = [super init]; + + if (self) + { + _editors = []; + _declaredKeys = []; + } + + return self; +} + +- (void)encodeWithCoder:(CPCoder)aCoder +{ + [aCoder encodeObject:_declaredKeys forKey:CPControllerDeclaredKeysKey]; +} + +- (id)initWithCoder:(CPCoder)aDecoder +{ + self = [self init]; + + if (self) + _declaredKeys = [aDecoder decodeObjectForKey:CPControllerDeclaredKeysKey] || _declaredKeys; + + return nil; +} + +- (BOOL)isEditing +{ + return [_editors count] > 0; +} + +- (BOOL)commitEditing +{ + for (var i=0, count=_editors.length; i