ftp.nice.ch/pub/next/science/mathematics/NeXTcontour.1.7.NIHS.bs.tar.gz#/NeXTcontour_1.7/Source/TextView.m

This is TextView.m in view mode; [Download] [Up]

/*
**  TextView.m, implementation of scrolling text stuff for TextLab.
**  Copyright 1989 NeXT, Inc.  All Rights Reserved.
**  Author: Bruce Blumberg
**
**  You may freely copy, distribute and reuse the code in this example.
**  NeXT disclaims any warranty of any kind, expressed or implied, as to
**  its fitness for any particular use.
*/

#import "TextView.h"
#import <appkit/Font.h>

@implementation TextView:ScrollView

- initFrame:(const NXRect *)frameRect
{
    NXRect rect = {0.0, 0.0, 0.0, 0.0};
	
    /* initialize view */
    [super initFrame:frameRect];
    
    /* specify scrollbars */
    [[self setVertScrollerRequired:YES] setHorizScrollerRequired:NO];

    [self getContentSize:&(rect.size)];
    theText = [self newText:&rect];
    [self setDocView:theText];
    [theText setSel:0 :0];	
    
    // The following two lines allow the resizing of the scrollview
    // to be passed down to the docView (in this case, the text view 
    // itself).

    [contentView setAutoresizeSubviews:YES];
    [contentView setAutosizing:NX_HEIGHTSIZABLE | NX_WIDTHSIZABLE];

    // Create enclosing window and bring it upfront
    [self makeEnclosingWindow:frameRect];
    [[[window setTitle:"List Data"] display] makeKeyAndOrderFront:self];
    	
    return self;
}

- makeEnclosingWindow:(const NXRect *)rect
{
    id	  textWindow;
    
    textWindow = [[Window alloc] initContent:rect
				 style:NX_RESIZEBARSTYLE
				 backing:NX_BUFFERED
				 buttonMask:(NX_CLOSEBUTTONMASK|
					     NX_MINIATURIZEBUTTONMASK)
				 defer:NO];
    [textWindow setContentView:self];
    [textWindow setBackgroundGray:NX_WHITE];
    [textWindow setFreeWhenClosed:YES];
    
    return self;
}
    
- newText:(const NXRect *)frameRect
{
    id	text;
    NXSize aSize = {1.0E38, 1.0E38};
    
    text = [[Text alloc] initFrame:frameRect
    			 text:NULL
			 alignment:NX_LEFTALIGNED];
    [text setOpaque:YES];
    [[[[[text notifyAncestorWhenFrameChanged:YES]
				setVertResizable:YES]
				    setHorizResizable:NO]
					setMonoFont:NO]
					    setDelegate:self];

    [text setFont:[Font newFont:"Courier" size:14.0]]; /* dcj */
    
    [text setMinSize:&(frameRect->size)];
    [text setMaxSize:&aSize];
    [text setAutosizing:NX_HEIGHTSIZABLE | NX_WIDTHSIZABLE];
    
    [text setCharFilter:NXEditorFilter];
    return text;
}

- provideTextObject
{
  return theText;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.