This is SwitchBox.m in view mode; [Download] [Up]
/*
** Copyright (C) 1992 Ronin Consulting, Inc.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; version 1.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#import "SwitchBox.h"
#import <appkit/Matrix.h>
#import <objc/List.h>
#define MAXPANEL 10
@interface SwitchBox(Private) /* No one should have to see this.... */
- setPanel0: anObject;
- setPanel1: anObject;
- setPanel2: anObject;
- setPanel3: anObject;
- setPanel4: anObject;
- setPanel5: anObject;
- setPanel6: anObject;
- setPanel7: anObject;
- setPanel8: anObject;
- setPanel9: anObject;
@end
@implementation SwitchBox
- initFrame:(const NXRect *)frameRect
{
[super initFrame:frameRect];
defaultPanel = -1;
[self setTitlePosition: NX_NOTITLE];
[self setBorderType: NX_BEZEL];
return self;
}
- switchToTagOf: sender;
{
if([sender isKindOf: [Matrix class]])
[self switchTo: [[sender selectedCell] tag]];
else
[self switchTo: [sender tag]];
return self;
}
- switchTo: (int) number;
{
if(delegate && [delegate respondsTo: @selector(willSwitchTo:)])
if(![delegate willSwitchTo: number])
return self;
if(number < 0 || number >= MAXPANEL)
return self;
[self setContentView: [panelList objectAt: number]];
if([self contentView])
{
[self setBorderType: NX_NOBORDER];
[self display];
if(delegate && [delegate respondsTo: @selector(didSwitchTo:)])
[delegate didSwitchTo: number];
}
return self;
}
- setDefaultPanel: (int) number
{
defaultPanel = number;
return self;
}
- setPanel: anObject at: (int) index
{
if(index < 0 || index >= MAXPANEL)
return self;
if(!panelList)
{
int x = MAXPANEL;
panelList = [[List alloc] initCount: MAXPANEL];
while(x--)
[panelList addObject: [self contentView]];
}
[panelList replaceObjectAt: index with: [anObject contentView]];
if(index == defaultPanel)
[self switchTo: defaultPanel];
return self;
}
- setDelegate: anObject
{
delegate = anObject;
return self;
}
- delegate
{
return delegate;
}
-read:(NXTypedStream *) s
{
[super read:s];
NXReadTypes(s, "i", &defaultPanel);
return self;
}
-write:(NXTypedStream *) s
{
[super write:s];
NXWriteTypes(s, "i", &defaultPanel);
return self;
}
-(const char *)inspectorName
{
return "SwitchBoxInspector";
}
@end
@implementation SwitchBox(Private)
- setPanel0: anObject
{
[self setPanel: anObject at: 0];
return self;
}
- setPanel1: anObject
{
[self setPanel: anObject at: 1];
return self;
}
- setPanel2: anObject
{
[self setPanel: anObject at: 2];
return self;
}
- setPanel3: anObject
{
[self setPanel: anObject at: 3];
return self;
}
- setPanel4: anObject
{
[self setPanel: anObject at: 4];
return self;
}
- setPanel5: anObject
{
[self setPanel: anObject at: 5];
return self;
}
- setPanel6: anObject
{
[self setPanel: anObject at: 6];
return self;
}
- setPanel7: anObject
{
[self setPanel: anObject at: 7];
return self;
}
- setPanel8: anObject
{
[self setPanel: anObject at: 8];
return self;
}
- setPanel9: anObject
{
[self setPanel: anObject at: 9];
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.