// Copyright (c) 1995 Don Yacktman.
// Use is governed by the MiscKit license.

#import "MiscStaticPickList.h"
#import <sys/param.h>

static MiscDictionary *availableLists = nil;

@implementation MiscStaticPickList

+ findPickListNamed:(MiscString *)aName
{
	if (!availableLists) {
		availableLists = [[MiscDictionary alloc] init];
	}
	if ([availableLists isKey:aName]) {
		return [availableLists valueForKey:aName];
	} else {
		MiscStaticPickList *theList = [[self alloc] initForListNamed:aName];
		[availableLists insertKey:aName value:theList];
		return theList;
	}
	return nil;
}

- popUp:sender
{
	[self reloadItemList]; // In case anything changed since last time
	// since we could have a mutable version floating around somewhere...
	return [super popUp:sender];
}

// These two are turned into no-ops so that we are immutable...
// But the .nib is missing the buttons anyway so this is only for
// completeness.  Note that you can still mutate things by playing
// with the dictionary yourself.  That will confuse the sorted key
// List, but would sort of work...

- addItemToList:(MiscString *)anItem value:(MiscString *)aValue { return nil; }
- removeItemFromList:(MiscString *)anItem { return nil; }

@end
