This is ToolIconView.m in view mode; [Download] [Up]
//************************************************************************ // // ToolIconView.m. // // by Felipe A. Rodriguez // // // This code is supplied "as is" the author makes no warranty as to its // suitability for any purpose. This code is free and may be distributed // in accordance with the terms of the: // // GNU GENERAL PUBLIC LICENSE // Version 2, June 1991 // copyright (C) 1989, 1991 Free Software Foundation, Inc. // 675 Mass Ave, Cambridge, MA 02139, USA // //************************************************************************ #import "ToolIconView.h" @implementation ToolIconView //***************************************************************************** // // init the appIconView // //***************************************************************************** - initFrame:(const NXRect *)bRect { [super initFrame:bRect]; [super setAutodisplay:YES]; [super notifyAncestorWhenFrameChanged:YES]; FrameImage = [NXImage findImageNamed: "frame"]; FrameBkImage = [NXImage findImageNamed: "frameBk"]; return self; } //************************************************************************ // // app Icon handling Methods // //************************************************************************ - (NXPoint) _centerPoint:anImage { NXSize appTileSize; NXSize imageSize; NXPoint centerPoint = {0,0}; // You must center the composited image within the contentView of the // appIcon window. [FrameImage getSize: &appTileSize]; [anImage getSize: &imageSize]; // center image and add offset to compensate for location of subview if( imageSize.width < appTileSize.width ) centerPoint.x += ((appTileSize.width - imageSize.width ) / 2.0) ; if( imageSize.height < appTileSize.height ) centerPoint.y += ((appTileSize.height - imageSize.height) / 2.0) ; return centerPoint; } //************************************************************************ // // NXAppTile is composited first at 0,0 of the icon window's content view // (this is required in order to maintain the NeXT icon look). 'anImage' // is then composited at center (centering is also a requirement). // //************************************************************************ - _display:anImage { NXPoint contentViewOrigin = {0.0, 0.0 }; NXPoint centerPoint = [self _centerPoint: anImage]; [FrameBkImage composite:NX_SOVER toPoint:&contentViewOrigin]; [anImage composite:NX_SOVER toPoint:¢erPoint]; [FrameImage composite:NX_SOVER toPoint:&contentViewOrigin]; return self; } - drawSelf:(const NXRect *)rects :(int)rectCount { [self _display:Image]; return self; } - (BOOL)acceptsFirstMouse { return YES; } - (BOOL)acceptsFirstResponder { return YES; } - resignFirstResponder { return nil; } //***************************************************************************** // // we will display the NXImage we are passed // //***************************************************************************** - setImage:theImage { Image = theImage; [self display]; return self; } //************************************************************************ // // free simply gets rid of everything we created // This is how nice objects clean up. // //************************************************************************ - free { return [super free]; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.