This is Divider.m in view mode; [Download] [Up]
/////////////////////////////////////////////////////////////////////////////// // FILENAME: Divider.m // SUMMARY: a trivial annotation denoting a logical/graphical divider. // SUPERCLASS: Object // INTERFACE: None // PROTOCOLS: <Annotation, Tool, ASCIISupport, HTMDSupport> // AUTHOR: Rohit Khare // COPYRIGHT: (c) 1994 California Institure of Technology, eText Project /////////////////////////////////////////////////////////////////////////////// // DESCRIPTION // Does its job by displaying a horizontal image the width of the window. /////////////////////////////////////////////////////////////////////////////// // HISTORY // 06/17/94: HTMD protocol added. RK and TRZ // 05/13/94: Created. First actual implementation. /////////////////////////////////////////////////////////////////////////////// #import "../eTextKernel.h" #define _DividerVERSION 10 @interface Divider:Object <Annotation, Tool, ASCIISupport, HTMDSupport,LaTeXSupport> { id theImage; id theText; int highlighted; NXCoord lMargin; } @end @implementation Divider + toolAwake:theApp { [theApp registerAnnotation: [Divider class] name: "Divider" RTFDirective: "Divider" menuLabel: "Insert Divider..." menuKey: '\0' menuIcon: (NXImage *) nil]; return self; } - init {[super init]; theImage = theText = nil; highlighted = 0; lMargin = 0.0; return self;} - initFromPboard:thePB inDoc:theDoc linked:(BOOL) linked {return [self init];} - calcCellSize:(NXSize *)theSize { NXCoord r,t,b; NXRect bounds; if (theText) { [theText getMarginLeft:&lMargin right:&r top:&t bottom:&b]; [theText getBounds:&bounds]; theSize->width = NX_WIDTH(&bounds) - lMargin - r; } else theSize->width = 1024.0; theSize->height = 6.0; return self; } - drawSelf:(const NXRect *)rect inView:view { NXRect tmpRect,bounds; theText = view; tmpRect.origin.x = lMargin; tmpRect.origin.y = NX_Y(rect) - NX_HEIGHT(rect); tmpRect.size.height = NX_HEIGHT(rect); tmpRect.size.width = NX_WIDTH(rect); [view getBounds:&bounds]; NXDrawButton(&tmpRect, &bounds); PSsetgray(NX_BLACK); //PSsetgray(highlighted ? NX_DKGRAY : NX_BLACK); //PSmoveto(lMargin, NX_Y(rect) + (NX_HEIGHT(rect)/2)); //PSsetlinewidth(2.0); //PSrlineto(NX_WIDTH(rect),0); //PSstroke(); return self; } - highlight:(const NXRect *)rect inView:view lit:(BOOL)flag {highlighted = !highlighted; NXHighlightRect(rect);return self;} - (BOOL) trackMouse:(NXEvent *)theEvent inRect:(const NXRect *)rect ofView:view {return NO;} - readRichText:(NXStream *)stream forView:view { int i; char c; if(c=NXGetc(stream)=='}') //version 0 NXUngetc(stream); else { NXUngetc(stream); NXScanf(stream, "%d ", &i); if (i != _DividerVERSION) { // bad version block. NXLogError("Divider found unparseable version %d at position %d", i, NXTell(stream)); return nil; } } return self; } - writeRichText:(NXStream *)stream forView:view { NXPrintf(stream,"%d ",_DividerVERSION);return self;} - writeASCII:(NXStream *)stream forView:view { NXPrintf(stream, "\n------------------------------------------------------------\n"); return self; } - writeLaTeX:(NXStream *) stream forView:view { NXPrintf(stream,"\n\\hrule\n"); return self; } - writeHTML:(NXStream *)stream forView:view { NXPrintf(stream,"\n<HR>\n"); return self; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.