This is SwapView.m in view mode; [Download] [Up]
/* Copyright 1993 Jeremy Slade. You are free to use all or any parts of the Locus project however you wish, just give credit where credit is due. The author (Jeremy Slade) shall not be held responsible for any damages that result out of use or misuse of any part of this project. */ /* Project: Locus File: SwapView Description: See SwapView.h Original Author: Jeremy Slade Revision History: Created V.101 JGS Sat Mar 6 20:27:59 GMT-0700 1993 */ #import "SwapView.h" #import "Globals.h" #import <objc/List.h> #import <dpsclient/psops.h> @implementation SwapView : View // ------------------------------------------------------------------------- // Creating, Initializing // ------------------------------------------------------------------------- + initialize { [self setVersion:SwapView_VERSION]; return ( self ); } - initFrame:(const NXRect *)frameRect { [super initFrame:frameRect]; replacementView = [[View allocFromZone:[self zone]] init]; return ( self ); } - free { // Remove the currentPane if installed if ( currentPane ) { [self setDelegate:nil]; // So we won't get a new pane when we [self swap]; // tell ourselves to swap panes } [replacementView free]; return ( [super free] ); } // ------------------------------------------------------------------------- // SwapView behavior // ------------------------------------------------------------------------- - setDelegate:anObject { delegate = anObject; return ( self ); } - delegate { return ( delegate ); } - swap:sender { [self swap]; return ( self ); } - swap { id installedView; // Un-install currentPane if installed if ( currentPane ) { installedView = [subviews objectAt:0]; [installedView removeFromSuperview]; // Remove it from our view list [currentPane setContentView:installedView]; // Put it back in its window currentPane = nil; } // Ask the delegate for the new pane if ( [delegate respondsTo:@selector(swapPaneFor:)] ) currentPane = [delegate swapPaneFor:self]; // Install the new pane as a subview our subivew: if ( currentPane ) { // Get the currentPane's contentView -- setting the replacementView as its // new contentView will return the old contentView installedView = [currentPane setContentView:replacementView]; // Install the new view as our subview [self addSubview:installedView]; [self display]; } return ( self ); } - drawSelf:(const NXRect *)rects :(int)rectCount /* Fill ourselves with the window's background color/gray */ { //if ( [self shouldDrawColor] ) // PSsetcolor ( ... ); //else PSsetgray ( [window backgroundGray] ); NXRectFill ( &bounds ); return ( self ); } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.