This is MiscDVInspector.m in view mode; [Download] [Up]
/***************************************************************************
* CLASS: MiscDVInspector (MiscDragViewInspector)
* Copyright (C) 1995 Robert Todd Thomas
* Use is governed by the MiscKit license
*
* See the header file for more info about this class.
***************************************************************************/
#import "MiscViews.subproj/MiscIconWell.h"
#import "MiscDVInspector.h"
@implementation MiscDVInspector
// Load the Inspector.
- init
{
char buf[MAXPATHLEN + 1];
id bundle;
[super init];
bundle = [NXBundle bundleForClass:[MiscDragView class]];
[bundle getPath: buf forResource: "MiscDVInspector" ofType:"nib"];
[NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
return self;
}
// This is called to set the options located on the inspector to
// be the same as the current selected object.
- revert: sender
{
// set all the radio buttons for dragging options
[ [optionMatrix cellAt: 0 :0] setState:[object allowSourceDragging] ];
[ [optionMatrix cellAt: 1 :0] setState:[object allowDestinationDragging] ];
[optionMatrix display]; // get matrix to redisplay values
// set icon stuff
[ [iconMatrix cellAt: 1 :0] setEnabled:[object allowDestinationDragging] ];
[ [iconMatrix cellAt: 0 :0] setStringValue:[object imageName] ];
[ [iconMatrix cellAt: 1 :0] setStringValue:[object acceptingImageName] ];
// set the border type
[borderMatrix selectCellWithTag: [object borderType] ];
[borderMatrix display];
return [super revert:sender];
}
// This method is called when one of the radio buttons in the inspector
// is clicked. The object is then notified of the change so that
// it can change it's state.
- optionsChanged: sender
{
BOOL state = [ [sender selectedCell] state];
switch ([ [sender selectedCell] tag])
{
case 0:
[object setAllowSourceDragging: state];
break;
case 1:
[object setAllowDestinationDragging: state];
break;
}
[window disableFlushWindow];
[self revert: sender];
[window reenableFlushWindow];
return [super ok: sender];
}
- iconsChanged: sender
{ const char *str;
if(str=[[iconMatrix cellAt: 0 :0] stringValue])
[object setImageByName:str];
if(str=[[iconMatrix cellAt: 1 :0] stringValue])
[object setAcceptingImageByName:str];
return [super ok: sender];
}
- borderChanged: sender
{ [object setBorderType: [ [borderMatrix selectedCell] tag] ];
[object display];
return [super ok: sender];
}
// Determines whether the inspector panel will have an "OK" and
// "Revert" button.
- (BOOL)wantsButtons
{ return NO;
}
@end
@implementation MiscDragView (IBInspector)
- (const char *)getInspectorClassName
{
return "MiscDVInspector";
}
@end
@implementation MiscIconWell (IBInspector)
- (const char *)getInspectorClassName
{ return "MiscIWInspector";
}
@end
@implementation MiscIWInspector
// Load the Inspector.
- init
{
char buf[MAXPATHLEN + 1];
id bundle;
[super init];
bundle = [NXBundle bundleForClass:[MiscDragView class]];
[bundle getPath: buf forResource: "MiscIWInspector" ofType:"nib"];
[NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
return self;
}
// This is called to set the options located on the inspector to
// be the same as the current selected object.
- revert: sender
{
// set all the check buttons for dragging options
[ [optionMatrix cellAt: 0 :0] setState:[object allowMFDragging] ];
[ [optionMatrix cellAt: 1 :0] setState:[object allowDoubleClickLaunch] ];
[optionMatrix display]; // get matrix to redisplay values
// string stuff ("icon" misleading)
[ [iconMatrix cellAt: 0 :0] setStringValue:[object fileTypes] ];
[ [iconMatrix cellAt: 1 :0] setStringValue:[object defaultName] ];
// set the border type
[borderMatrix selectCellWithTag: [object borderType] ];
[borderMatrix display];
return [super revert:sender];
}
// This method is called when one of the radio buttons in the inspector
// is clicked. The object is then notified of the change so that
// it can change it's state.
- optionsChanged: sender
{
BOOL state = [ [sender selectedCell] state];
switch ([ [sender selectedCell] tag])
{
case 0:
[(MiscIconWell*)object setAllowMFDragging: state];
break;
case 1:
[(MiscIconWell*)object setAllowDoubleClickLaunch: state];
break;
}
[window disableFlushWindow];
[self revert: sender];
[window reenableFlushWindow];
return [super ok: sender];
}
- iconsChanged: sender
{ const char *str;
if(str=[[iconMatrix cellAt: 0 :0] stringValue])
[object setFileTypes:str];
if(str=[[iconMatrix cellAt: 1 :0] stringValue])
[(MiscIconWell*)object setDefaultName:str];
return [super ok: sender];
}
- borderChanged: sender
{ [object setBorderType: [ [borderMatrix selectedCell] tag] ];
[object display];
return [super ok: sender];
}
// Determines whether the inspector panel will have an "OK" and
// "Revert" button.
- (BOOL)wantsButtons
{ return NO;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.