This is SubViewFramer.m in view mode; [Download] [Up]
//
// A View that Frames its Subview -- pretty ungeneral
// Randy Nelson, NeXT Developer Training
// Created 5-1-90
// Modified for 2.0 9-3-90
//
// You may freely copy, distribute and reuse the code in this example.
// NeXT disclaims any warranty of any kind, expressed or implied, as to
// its fitness for any particular use.
//
#import "SubViewFramer.h"
#import <dpsclient/wraps.h>
#import <appkit/graphics.h>
#import "VisibleOne.h"
#define FACTOR 2
@implementation SubViewFramer
//sets clipping off
- initFrame:(const NXRect *)r
{
[super initFrame:r];
[self setClipping:NO];
return self;
}
//called by the visible view to frame itÐtransparently if requested
- frameMe:sender
{
NXRect subViewsFrame, myFrame;
NXSize myFrameFactored;
float subViewsFrameAngle;
[self lockFocus];
PSsetgray(0.5);
//gets the subview's frame and rotation
[sender getFrame:&subViewsFrame];
subViewsFrameAngle = [sender frameAngle];
//necessary to rotate around the same point the subview used if rotated
if(subViewsFrameAngle != 0){
PStranslate(subViewsFrame.origin.x, subViewsFrame.origin.y);
PSrotate(subViewsFrameAngle);
PStranslate(-subViewsFrame.origin.x, -subViewsFrame.origin.y);
}
//sets the alpha if sender wants a transparent superview
if ([sender wantsTransparency]){
PSsetalpha(NX_DKGRAY);
}
//the superview needs to completely cover the window
//even when rotated
[self getFrame:&myFrame];
myFrameFactored.width = (myFrame.size.width * FACTOR);
myFrameFactored.height = (myFrame.size.height * FACTOR);
//left side
PScompositerect(-(myFrameFactored.width), -(myFrameFactored.height),
((myFrameFactored.width) + subViewsFrame.origin.x),
(myFrameFactored.height * 2), NX_SOVER);
//top middle
PScompositerect(subViewsFrame.origin.x,
(subViewsFrame.origin.y + subViewsFrame.size.height),
subViewsFrame.size.width,
((myFrameFactored.height)
- (subViewsFrame.origin.y + subViewsFrame.size.height)),
NX_SOVER);
//right side
PScompositerect((subViewsFrame.origin.x + subViewsFrame.size.width),
-(myFrameFactored.height),
((myFrameFactored.width)
- (subViewsFrame.origin.x + subViewsFrame.size.width)),
(myFrameFactored.height * 2), NX_SOVER);
//bottom middle
PScompositerect(subViewsFrame.origin.x, -(myFrameFactored.height),
subViewsFrame.size.width,
((myFrameFactored.height) + subViewsFrame.origin.y), NX_SOVER);
//enclose the subview's frame
PSsetgray(NX_BLACK);
PSsetalpha(1.0);
NXFrameRect(&subViewsFrame);
[self unlockFocus];
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.