ftp.nice.ch/pub/next/tools/system/LoginStats.NIHS.bs.tar.gz#/LoginStats/Source/ScrollViewExample.m

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

/*      Generated by Interface Builder 
**	You may freely copy, distribute and reuse the code in this example.
**	Eric Tremblay disclaims any warranty of any kind, expressed or implied, **      as to its fitness for any particular use.
**      July 26, 1992
*/

#import "MyObject.h"

@implementation MyObject


- appDidInit:sender
{

        /* Set the ScrollView to accept graphics */
        /* Impliment drag and drop graphics using one line! */
	[[MyScrollView docView] setGraphicsImportEnabled:YES];
        return self;
}


- textLengthTest:sender
/* The number of characters in the Text object . */
{
         int HowLongIsTheText;	
	 
	 document = [MyScrollView docView];

         /* assigns the length of the text in MyScrollView */
         HowLongIsTheText = [document textLength]; 

        /* Displays how many characters is in the text */
        [theTextLength setIntValue:HowLongIsTheText]; 
        return self;
}

- selectTextTest:sender
/* This selects "highlights" the text in MyScrollView */
{
     [[MyScrollView docView] selectText:document];

	return self;
 }
 
 - checkSpellingTest:sender
 /* This checks the spelling of the text in the MyScrollView document */
 {
  	document = [MyScrollView docView];
	[[MyScrollView docView] checkSpelling:document]; /* Spell check */
	[[MyScrollView docView] showGuessPanel:document]; /* Guess and replace panel */
	return self;
 }

- byteLengthTest:sender
/* This displays how many bytes are used in the text of MyScrollView */
{
       int HowManyBytes;
       document = [MyScrollView docView];
       HowManyBytes = [document byteLength]; 
       [theByteLength setIntValue:HowManyBytes];
       return self;
 }


- setTextTest:sender
/* This takes the text in setTextInput and displays it in MyScrollView */
{
       const char *inputString;
       inputString = [setTextInput stringValue];
       [[MyScrollView docView] setText:inputString];
       return self;
}

- appendTextTest:sender
/* This will get the text in appendTextInput and add it at the end of MyScrollView */
{
    	int HowLongIsTheText;
   	const char *inputString;
     
        inputString = [appendTextInput stringValue]; /* gets the inputString */
	
	document = [MyScrollView docView];
 	
	/* Determines how many characters are in MyScrollViews document */
	HowLongIsTheText = [document textLength]; 
  	
	/* Selects and empty selection, which in fact places the cursor at the end of the document */
	[document setSel:HowLongIsTheText:HowLongIsTheText];
        
	/* Replaces the selection (in this case it is empty) with inputString */
	[document replaceSel:inputString]; 

	return self;
}

- backWhite:sender
/* This will change the background color of MyScrollView */
{
   	[[MyScrollView docView] setBackgroundGray:NX_WHITE];
   	[MyScrollView display];
	return self;
}


- backBlack:sender
/* This will change the background color of MyScrollView */
{
 	[[MyScrollView docView] setBackgroundGray:NX_BLACK];
   	[MyScrollView display];
	return self;
}


- backLgray:sender
/* This will change the background color of MyScrollView */
{
 	[[MyScrollView docView] setBackgroundGray:NX_LTGRAY];
   	[MyScrollView display];
	return self;
}


- backDgray:sender
/* This will change the background color of MyScrollView */
{
 	[[MyScrollView docView] setBackgroundGray:NX_DKGRAY];
   	[MyScrollView display];
	return self;
}


- textWhite:sender
/* changes the color of the text in MyScrollView */
{
     	[[MyScrollView docView] setTextGray:NX_WHITE];
     	[MyScrollView display];
     	return self;
 }

- textBlack:sender
/* changes the color of the text in MyScrollView */
{
     	[[MyScrollView docView] setTextGray:NX_BLACK];
     	[MyScrollView display];
     	return self;
 }

- textLgray:sender
/* changes the color of the text in MyScrollView */
{
     	[[MyScrollView docView] setTextGray:NX_LTGRAY];
     	[MyScrollView display];
     	return self;
 }

- textDgray:sender
/* changes the color of the text in MyScrollView */
{
     	[[MyScrollView docView] setTextGray:NX_DKGRAY];
     	[MyScrollView display];
     	return self;
 }

- PrintScroll:sender
/* This method will print the scrollView to the printer */
// Printing is rather simple; just send printPSCode: to the text view
// you wish to print. The print panel will automatically pop up and unless
// the user cancels the printout the text view will be printed.
{
  
    [[MyScrollView docView] printPSCode:self];
    return self;
 }

- PrintWindow:sender
/* This method will print the WHOLE panel to the printer */

{
  
    [TheWindow printPSCode:self];
    return self;
 }

- Ruler:sender
/* This method toggles a rular in the scrollview */
{
    [[MyScrollView docView] toggleRuler:self];
    return self;
}

- Left:sender
/* This will justify the text to the left */
{

    [[MyScrollView docView] setAlignment:NX_LEFTALIGNED];
    [MyScrollView display];
    return self;
}

- Right:sender
/* This will justify the text to the right */
{

    [[MyScrollView docView] setAlignment:NX_RIGHTALIGNED];
    [MyScrollView display];
    return self;
}

- Center:sender
/* This will justify the text to the Centered */
{

    [[MyScrollView docView] setAlignment:NX_CENTERED];
    [MyScrollView display];
    return self;
}

- Save:sender
{
	int fd;
	NXStream *thestream;
	
	fd = open("TEST.rtfd", O_WRONLY|O_CREAT|O_TRUNC, 0666);
	
	thestream = NXOpenFile(fd, NX_WRITEONLY);
	[[MyScrollView docView] writeRichText:thestream];
	
	NXClose(thestream);
	close(fd);
	
	return self;
	
}


- Load:sender
{
	int fd;
	NXStream *thestream;
	
	fd = open("TEST.rtfd", O_RDONLY, 0666);
	
	thestream = NXOpenFile(fd, NX_READONLY);
	[[MyScrollView docView] readRichText:thestream];
	
	NXClose(thestream);
	close(fd);
	
	return self;
}


@end

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