Path: utzoo!attcan!uunet!ogicse!milton!lshupe From: lshupe@milton.u.washington.edu (Larry Shupe) Newsgroups: comp.sys.next Subject: Re: Black Hole, we hardly new ya' Message-ID: <8205@milton.u.washington.edu> Date: 27 Sep 90 15:19:52 GMT References: <400@kaos.MATH.UCLA.EDU> <0b0CBPi00WBNE2Z9cw@andrew.cmu.edu> Distribution: na Organization: University of Washington, Seattle Lines: 93 My vote for naming the next next NeXT: Cube, Slab, Wafer (because it will be just waaahfer thin!) There have been a couple of requests a simple graphics example using the NeXT Step interface. Paul Haeberli posted some code for an Iris workstation graphics example, and I have translated this to NeXT Step. This example is self contained and does not use Interface Builder, but at least non-NeXT programmers should be able to see how it works. ------------ Cut Here ----------------- // File name: Dinky.m // Larry Shupe // Sept 26, 1990 // // A trivial paint program for a NeXT. // Some source code stolen from the "little" demo. // Compile with: cc -O -g -Wimplicit -o Dinky Dinky.m -lNeXT_s -lsys_s #import ///////////////////////////////////////////////////////////////////////// // Define a class for drawing circles when user clicks the mouse. @interface PaintView:Control { /* No instance variables */ } - clear:sender; // Action method to erase painting to white. @end @implementation PaintView - clear:sender { [self lockFocus]; // Sets up clipping path etc. NXEraseRect(&bounds); // Erase the current painting. PSflushgraphics(); // Update the screen now. [self unlockFocus]; return self; } - mouseDown:(NXEvent *)theEvent // Called by system when mouse clicked. { NXPoint center = theEvent->location; [self convertPoint:¢er fromView:nil]; // From Global to Local coords. [self lockFocus]; PSnewpath(); PSarc(center.x, center.y, 36, 0, 360); // PostScript for a circle. PSsetgray(NX_BLACK); PSstroke(); PSflushgraphics(); [self unlockFocus]; return self; } @end ///////////////////////////////////////////////////////////////////////// void setUp(void) { NXRect rectangle; id myWindow, myPainting, myMenu; NXSetRect(&rectangle, 100.0, 350.0, 300.0, 300.0); myWindow = [Window newContent:&rectangle style:NX_TITLEDSTYLE backing:NX_BUFFERED buttonMask:NX_MINIATURIZEBUTTONMASK defer:NO]; NXSetRect(&rectangle, 0.0, 0.0, 300.0, 300.0); myPainting = [PaintView newFrame:&rectangle]; [myWindow setContentView:myPainting]; [[myWindow display] makeKeyAndOrderFront:nil]; myMenu = [Menu newTitle:"Dinky"]; [[myMenu addItem:"Clear" action:@selector(clear:) keyEquivalent:'\0'] setTarget:myPainting]; [myMenu addItem:"Quit" action:@selector(terminate:) keyEquivalent:'q']; [myMenu sizeToFit]; [NXApp setMainMenu:myMenu]; } main() { [Application new]; // Create new application object. setUp(); // Setup the window and the menu. [NXApp run]; // Run the application until user quits. [NXApp free]; } ------------ Cut Here ----------------- Larry Shupe lshupe@milton.u.washington.edu