ftp.nice.ch/pub/next/developer/resources/classes/misckit/MiscKit.1.10.0.s.gnutar.gz#/MiscKit/Examples/TreeView/SavePanelWithPopUp.subproj/SavePanelWithPopUp.m

This is SavePanelWithPopUp.m in view mode; [Download] [Up]

//		Written by Aleksey Sudakov <zander@cnext.crec.mipt.ru>
//          Copyright (c) 1995 by Aleksey Sudakov.
//				Version 1.0.  All rights reserved.
//
//		This notice may not be removed from this source code.
//
//	This program is included in the MiscKit by permission from the author
//	and its use is governed by the MiscKit license, found in the file
//	"LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
//	for a list of all applicable permissions and restrictions.
//	

#import <objc/List.h>
#import <misckit/MiscString.h>
#import "SavePanelWithPopUp.h"

@interface SavePanelWithPopUp(Private)
+ _factory;

- _init;
- changeTypes;
@end

@implementation SavePanelWithPopUp
+ _factory
{
    return [SavePanelWithPopUp class];
}

+ newContent:(const NXRect *)contentRect style:(int)aStyle
	backing:(int)bufferingType buttonMask:(int)mask defer:(BOOL)flag
{
	SavePanelWithPopUp* panel;

	panel = [SavePanel newContent:contentRect style:aStyle
			backing:bufferingType buttonMask:mask defer:flag];
	return [panel _init];
}

- _init
{	
	types = [[List alloc] init];
	popUp = [[PopUpList alloc] init];
	[popUp setTarget:self];
	[popUp setAction:sel_getUid("changeTypes")];

	return self;
}

- changeTypes
{
	[self setSelectedType:[[types objectAt:[[popUp itemList] selectedRow]] stringValue]];
	[self setRequiredFileType:selectedType];
	return self;
}

- registerPopUp
{
	[super setAccessoryView:NXCreatePopUpListButton(popUp)];
	return self;
}

- addType:(char*)type withDescription:(char*)description
{
	MiscString* msType = [MiscString newWithString:type];
	MiscString* msTitle = [[MiscString alloc] initFromFormat:
								"%s - %s",type, description];

	[popUp addItem:[msTitle stringValue]];
	[types addObject:msType];
	if(!selectedType){
		[self setSelectedType:[[types objectAt:0] stringValue]];
		[self setRequiredFileType: selectedType];
		}
	return self;
}

- (char*)selectedType
{
	return selectedType;
}

- setSelectedType:(const char *)aString
{
	if (selectedType) free(selectedType);
	selectedType = NXCopyStringBufferFromZone(aString, [self zone]);
	return self;
}

- free
{
	free(selectedType);
	[types freeObjects];
	[types free];
	[popUp free];
	return [super free];
}


@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.