ftp.nice.ch/pub/next/developer/objc/appkit/Lab1234.s.tar.gz#/Lab3/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, NeXT Developer Support Group
*/

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

@implementation TextView:View

+newFrame:(const NXRect *)tFrame
{	NXRect rect;
	
    /*			EXERCISE #1 				*
    *	Turn this into a subclass of a ScrollView and set	*
    *	the docView of the scrolling view to the text object 	*
    *	returned by the -newText: method of TextView.		*
    *	Before you call newText: you will need to determine the	*
    *	size of the text object you want newText: to create for	*
    *	you. It should be the same size of the scrollView less  *
    * 	the size of the scrollers. There is a method of         *
    *	ScrollView which will give you this information. Also 	*
    *	note that in a ScrollView you do not have to explicitly *
    *	make the view you are scrolling over (the docView) a	*
    * 	subview of the ScrollView. That is done for you when you*
    * 	set the docView of the ScrollView			*/

    /* create view */
    self = [super newFrame:tFrame];
    theText = [self newText:&bounds];
    [self addSubview:theText];
    
    // The following two lines allow the resizing of the view
    // to be passed down to the docView (in this case, the text view 
    // itself).

    [[theText superview] setAutoresizeSubviews:YES];
    [[theText superview] setAutosizing:NX_HEIGHTSIZABLE | NX_WIDTHSIZABLE];

     // Create enclosing window, display it and bring it upfront
    [self makeEnclosingWindow:tFrame];
    [window makeFirstResponder:theText];
    [window setTitle:"Untitled"];
    [window display];
    [window makeKeyAndOrderFront:self];
    [theText setSel:0:0];	
    return(self);
}

-makeEnclosingWindow:(const NXRect *)r
{
    id tWin;
    
    tWin = [Window newContent:r style:NX_TITLEDSTYLE 
		backing:NX_BUFFERED buttonMask:NX_ALLBUTTONS defer:NO];
    [tWin setContentView:self];
    [tWin setBackgroundGray:NX_WHITE];
    [tWin setFreeWhenClosed:YES];
    return self;
}

-newText:(const NXRect *)tF
{
	id text = [Text newFrame:tF text:NULL alignment:NX_LEFTALIGNED];
	[text setOpaque:YES];
	[[[[[text notifyAncestorWhenFrameChanged:YES]
		setVertResizable:YES]
		setHorizResizable:NO]
		setMonoFont:NO]
		setDelegate:self];
	
	{ NXSize aSize = {1.0E38,1.0E38};
	 [text setMinSize:&tF->size];
	 [text setMaxSize:&aSize];
        }
	[text setCharFilter:NXEditorFilter];
	return text;
}
@end
	
 

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