This is DragImageView.m in view mode; [Download] [Up]
/* $Id: DragImageView.m,v 1.1 1996/10/12 14:30:34 vkyr Exp vkyr $ */
#import <appkit/appkit.h>
#import "Controller.h"
#import "DragImageView.h"
@implementation DragImageView
- initFrame:(const NXRect *)theFrame
{
const char *const types[] = {NXFilenamePboardType};
[super initFrame:theFrame];
[self registerForDraggedTypes:(const char *const *)&types count:1];
return self;
}
- (NXDragOperation)draggingEntered:sender
{
if (([sender draggingSourceOperationMask] & NX_DragOperationGeneric) &&
([sender draggingSource] != self))
{
newImage = [[NXImage alloc] initFromSection:"manopen.tiff"];
[self setImage:newImage];
return NX_DragOperationGeneric;
}
return NX_DragOperationNone;
}
- (NXDragOperation)draggingUpdated:sender
{
if (([sender draggingSourceOperationMask] & NX_DragOperationGeneric) &&
([sender draggingSource] != self))
{
return NX_DragOperationGeneric;
}
return NX_DragOperationNone;
}
- (BOOL)performDragOperation:sender
{
if (![sender isDraggingSourceLocal] && ([sender draggingSource] != self))
{
newImage = [[NXImage alloc] initFromSection:"manopen_dvi.tiff"];
[self setImage:newImage];
}
return YES;
}
- draggingExited:sender
{
newImage = [[NXImage alloc] initFromSection:"man.tiff"];
[self setImage:newImage];
return self;
}
- concludeDragOperation:sender
{
id workspace;
int length;
BOOL fileFound;
NXAtom theFileType;
Pasteboard *pboard;
char *data = '\0';
const char *appName = '\0';
pboard = [sender draggingPasteboard];
[pboard readType:NXFilenamePboardType data:&data length:&length];
workspace = [Application workspace];
fileFound = [workspace getInfoForFile:data
application:&appName
type:&theFileType];
if (fileFound)
{
if (strcmp(theFileType,"dvi") == 0)
{
[controlObj openDviFile:data];
newImage = [[NXImage alloc] initFromSection:"man.tiff"];
}
else
{
newImage = [[NXImage alloc] initFromSection:"manopen_nodvi.tiff"];
[[controlObj getPages] setIntValue: 0];
[[controlObj getWidth] setDoubleValue: 0.0];
[[controlObj getHeight] setDoubleValue: 0.0];
[[[controlObj getFonts] docView] setText:""];
[[controlObj getMyWindow] setTitle:"NO DVI FILE"];
[[controlObj getMyUnits] setEnabled: NO];
[[controlObj getOpenButton] setEnabled: NO];
}
}
[self setImage:newImage];
[pboard deallocatePasteboardData:data length:length];
return self;
}
- drawSelf:(const NXRect *)rects :(int)count
{
PSsetgray(NX_LTGRAY);
NXRectFill(&bounds);
if(newImage)
[newImage composite:NX_SOVER toPoint:&bounds.origin];
return self;
}
- setImage:aImage
{
newImage = aImage;
[newImage setSize:&bounds.size];
[self display];
return self;
}
- setScaleState:(BOOL)state
{
sSwitch = state;
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.