jimmyc@casbah.acns.nwu.edu (James Choi) (06/04/91)
I am having trouble putting a dot on the NeXT screen. Could someone show me how to do it with a compilable sample source code? Thank you in advance James Choi
burchard@math.utah.edu (Paul Burchard) (06/05/91)
In article <1991Jun4.134204.28921@casbah.acns.nwu.edu> jimmyc@casbah.acns.nwu.edu (James Choi) writes: > > I am having trouble putting a dot on the NeXT screen. Could someone show > me how to do it with a compilable sample source code? I give here *complete* directions---you will write < 10 lines of code! Start Interface Builder, select New Application from the menu. Get the Inspector panel from the Tools menu, first switching it to Project mode and clicking OK to create a project file (these will go in your home dir for now...sorry). Next switch the Inspector to Class mode. In the class browser window, select the View class (under Responder), Subclass it, and then Unparse the new class to generate code templates. Go back to the Project Files Inspector, find MyView.[hm], and click the Open button. The two files pop up for editing. In MyView.h, add the line - drawSelf:(const NXRect *)rects :(int)rectCount; just before the @end. Saving that, add this to MyView.m just before the @end: #import <appkit/appkit.h> -drawSelf:(const NXRect *)rects :(int)rectCount { PSsetgray(0.); PSnewpath(); PSmoveto(10.,10.); PSlineto(10.,10.); PSstroke(); return self; } Save this file too. From the IB Palettes, drag-and-drop a CustomView into the "MyWindow" window (use the resize knobs to make the View fill the Window). In the Attributes Inspector, choose its class to be "MyView" from the scrolling list. Save As into "myapp.nib". Select ".nib" in the Project Files inspector and click Add; double-click on myapp.nib in the pop-up browser to incorporate it. Finally, choose Save All, and then Make, from the IB menu. You will now have an Application in your home dir called myapp.debug. Launch it. Enjoy your "one point of light" :-) ----------------------------------------------------------------------------- Paul Burchard <burchard@math.utah.edu> ``I'm still learning how to count backwards from infinity...'' -----------------------------------------------------------------------------
ly@neon.Stanford.EDU (Eric Ly) (06/05/91)
In article <1991Jun5.055531.6189@fcom.cc.utah.edu> burchard@math.utah.edu (Paul Burchard) writes: >In article <1991Jun4.134204.28921@casbah.acns.nwu.edu> >jimmyc@casbah.acns.nwu.edu (James Choi) writes: >> >> I am having trouble putting a dot on the NeXT screen. Could someone show >> me how to do it with a compilable sample source code? > [explanation deleted...] Actually, there's a much more efficient way of doing it. Let's say you want to put a dot at a location given by an NXPoint. Then, the following function will put your dot on the screen: void doDot(const NXPoint *point) { NXRect rect; rect.origin = point->origin; rect.size.width = rect.size.height = 1.0; NXRectFill(&rect); } It's more efficient for various reasons, but basically, it uses one optimized Display PostScript operator rather than several PostScript operators. Eric Ly Stanford University